Gatsby и Strapi: конкретные c экземпляров данных, запрошенных от Gatsby, возвращают null, несмотря на то, что они существуют в Strapi - PullRequest
0 голосов
/ 06 августа 2020

Я запрашиваю данные из Strapi с помощью Gatsby. Определенные c запросы «где» возвращают null, несмотря на то, что они существуют в CMS. Это происходит со многими экземплярами этих данных (примерно 20 из 120 страниц.

Например, эта страница вообще не отображается: https://flutterbyexample.com/lesson/bring-it-all-together

Сравните это с этим: https://flutterbyexample.com/lesson/wrap-the-pegs-in-animated-widgets

Наконец, когда я напрямую пингую API, содержимое действительно существует. Итак, я думаю, что это проблема с Гэтсби.

Нет ошибок в консоли или при локальном запуске gatsby build. gatsby clean тоже не помогает.

Справочная информация:

  • данные, которые я запрашиваю из Strapi, находятся в коллекции под названием lesson
  • Strapi развернут в Heroku, и эта часть API publi c

Запросы Гэтсби:

Этот запрос не работает:

{
  strapiLesson(slug: {eq: "bring-it-all-together"}) {
    id
    author {
      email
      username
      twitter
    }
    content
    updated_at(formatString: "dddd, Do of MMMM, YYYY")
    slug
    strapiId
    title
    tutorial {
      category
      title
    }
  }
}


RETURNS:
{
  "data": {
    "strapiLesson": null
  }
}

Для потомков успешный запрос:

{
  strapiLesson(slug: {eq: "about-dart"}) {
    id
    author {
      email
      username
      twitter
    }
    content
    updated_at(formatString: "dddd, Do of MMMM, YYYY")
    slug
    strapiId
    title
    tutorial {
      category
      title
    }
  }
}


RETURNS

{
  "data": {
    "strapiLesson": {
      "id": "Lesson_1",
      "author": {
        "email": "eric@ericwindmill.com",
        "username": "Eric Windmill",
        "twitter": "ericwindmill"
      },
      "content": "...",
      "updated_at": "Sunday, 12th of July, 2020",
      "slug": "about-dart",
      "strapiId": 1,
      "title": "About Dart",
      "tutorial": {
        "category": "Dart",
        "title": "Getting Started with Dart"
      }
    }
  }
}

Опять же, если я пингую API непосредственно для lesson со слизней bring-it-all-together, я получаю это JSON. Итак, я знаю, что API работает.

[
  {
    "id": 121,
    "title": "Bring it all together",
    "author": {
      "id": 1,
      "username": "Eric Windmill",
      "email": "eric@ericwindmill.com",
      "provider": "local",
      "confirmed": true,
      "blocked": false,
      "role": 1,
      "twitter": "ericwindmill",
      "bio": "Creator of Flutter by Example. Author of Flutter in Action. Located in lovely Portland, Oregon.",
      "created_at": "2020-07-06T19:22:22.529Z",
      "updated_at": "2020-07-11T16:32:52.601Z",
      "profile_image": null
    },
    "content": "...",
    "slug": "bring-it-all-together",
    "tutorial": {
      "id": 9,
      "title": "Custom Animation: Progress Indicator",
      "category": "Flutter",
      "author": 1,
      "created_at": "2020-07-24T16:49:09.645Z",
      "updated_at": "2020-07-24T16:50:23.886Z"
    },
    "created_at": "2020-08-06T15:24:05.612Z",
    "updated_at": "2020-08-06T15:24:05.624Z"
  }
]

Последняя, ​​забавная вещь, чтобы снова усилить, что Strapi, казалось бы, работает, заключается в том, что когда я запрашиваю tutorial, у которого есть взаимно много ассоциаций с lesson, метаинформация об уроке null действительно присутствует. Это запрос GraphQL:

{
  strapiLesson(slug: {eq: "bring-it-all-together"}) {
    id
    author {
      email
      username
      twitter
    }
    content
    updated_at(formatString: "dddd, Do of MMMM, YYYY")
    slug
    strapiId
    title
    tutorial {
      category
      title
    }
  }
  strapiTutorial(title: {eq: "Custom Animation: Progress Indicator"}) {
    lessons {
      author
      created_at
      id
      slug
      title
      tutorial
      updated_at
    }
  }
  strapiTableOfContents {
    contents
  }
}

RETURNS:

{
  "data": {
    "strapiLesson": null,  // <--- lesson data should be here
    "strapiTutorial": {
      "lessons": [
        {
          "author": 1,
          "created_at": "2020-07-24T17:01:01.352Z",
          "id": 83,
          "slug": "build-the-example-app-boiler-plate",
          "title": "Build the example app boiler-plate",
          "tutorial": 9,
          "updated_at": "2020-07-24T17:01:01.364Z"
        },
        {
          "author": 1,
          "created_at": "2020-07-24T17:41:14.728Z",
          "id": 86,
          "slug": "tween-by-example",
          "title": "Tween by example",
          "tutorial": 9,
          "updated_at": "2020-07-24T17:41:14.736Z"
        },
        {
          "author": 1,
          "created_at": "2020-07-24T17:42:02.927Z",
          "id": 88,
          "slug": "wrap-the-pegs-in-animated-widgets",
          "title": "Wrap the Pegs in AnimatedWidgets",
          "tutorial": 9,
          "updated_at": "2020-08-05T19:12:37.252Z"
        },
        {
          "author": 1,
          "created_at": "2020-07-24T17:40:51.308Z",
          "id": 85,
          "slug": "tween-and-animation-controller-classes",
          "title": "Tween and AnimationController classes",
          "tutorial": 9,
          "updated_at": "2020-07-24T17:40:51.317Z"
        },
        {
          "author": 1,
          "created_at": "2020-07-24T17:00:31.617Z",
          "id": 82,
          "slug": "progress-indicator-intro-and-overview",
          "title": "Intro and Overview",
          "tutorial": 9,
          "updated_at": "2020-07-24T17:00:31.627Z"
        },
        {
          "author": 1,
          "created_at": "2020-08-06T15:24:05.612Z",
          "id": 121,
          "slug": "bring-it-all-together",          // <-- the data exists
          "title": "Bring it all together",
          "tutorial": 9,
          "updated_at": "2020-08-06T15:24:05.624Z"
        },
        {
          "author": 1,
          "created_at": "2020-07-24T17:41:39.161Z",
          "id": 87,
          "slug": "using-tweens-and-intervals",
          "title": "Using Tweens and Intervals",
          "tutorial": 9,
          "updated_at": "2020-07-24T17:41:39.173Z"
        },
        {
          "author": 1,
          "created_at": "2020-07-24T17:01:38.537Z",
          "id": 84,
          "slug": "custom-widget-peg",
          "title": "Custom Widget: Peg",
          "tutorial": 9,
          "updated_at": "2020-07-24T17:01:38.546Z"
        }
      ]
    }
  }
}

1 Ответ

0 голосов
/ 06 августа 2020

Невероятно. Такая глупая ошибка. Потраченные впустую часы.

В моей конфигурации gatsby-config плагина gatsby-source-strapi у меня был установлен лимит запросов на 100.

...