thinhle-agilityio / gatsby-source-apiserver

A gatsby source plugin for pulling data from api server.
63 stars 34 forks source link

Graph does not see some fields and does not generate the scheme correctly #47

Open SaiRO97 opened 4 years ago

SaiRO97 commented 4 years ago

Hello, I have categories in the project. I need to get all fields from an endpoint in graphql. But the schema does not generate correctly, the children field at my endpoint always returns an empty array when I make a request

data from server

[
    {
        "id": 1,
        "nameI18nId": 238,
        "slug": "test",
        "name": {
            "id": 238,
            "en": "Test",
            "ru": "Тест"
        },
        "children": [
            {
                "id": 10,
                "nameI18nId": 548,
                "slug": "product-category-name",
                "name": {
                    "id": 548,
                    "en": "product category name",
                    "ru": "категория продукта"
                },
        ]
]

gatsby config file

{
      resolve: `gatsby-source-apiserver`,
      options: {
        url: process.env.PAYFORM_API_URL,
        method: 'get',
        typePrefix: 'internal__',
        name: 'payform',
        headers: {
          'Content-Type': 'application/json',
        },
        verboseOutput: true,
        entitiesArray: [
          {
            url: `${process.env.PAYFORM_API_URL}product`,
            method: 'get',
            headers: {
              'Content-Type': 'application/json',
            },
            typePrefix: 'internal__',
            name: `products`,
          },
          {
            url: `${process.env.PAYFORM_API_URL}product-category`,
            method: 'get',
            headers: {
              'Content-Type': 'application/json',
            },
            typePrefix: 'internal__',
            name: `categories`,
          },
        ],
      },

How can I get data in the children field? If you have any ideas, please let me know how I can fix this. thanks