AndreasFaust / gatsby-source-custom-api

Source data from any API and transform it to (File-)Nodes.
52 stars 25 forks source link

Schema hierarchy / image not being downloaded #32

Open a-rbsn opened 3 years ago

a-rbsn commented 3 years ago

I've encountered some strange behaviour — I'm building my schemas and it appears that I have to choose between either my images downloading, or to have my api being brought in correctly. The two options I am presented with:

  1. Have my data being brought in with the correct hierarchy (in my case: conferences->events->image), but the images don't get downloaded.
  2. Have my data being brought in with a flat hierarchy (conferences, events->image) and with the images downloading.

My api looks like this: image

to have the correct hierarchy I need to use this config:

    {
      resolve: "gatsby-source-custom-api",
      options: {
        url: {
          production: "http://sculpture-poetry-cms.test/conferences.json",
          development: "http://sculpture-poetry-cms.test/conferences.json",
        },
        auth: {
          username: "username",
          password: "password",
        },
        rootKey: "spConferences",
        schemas: {
          spConferences: `
            conference: [conference]
          `,
          conference: `
            uid: String
            title: String
            description: String
            location: String
            byline: String
            startDate: String
            endDate: String
            button: button
            events: [event]
          `,
          event: `
            uid: String
            slug: String
            url: String
            title: String
            type: String
            description: String
            image: image
            eventLink: eventLink
            speakers: [speaker]
            date: String
            startTime: String
            endTime: String
          `,
          image: `
            url: String
            modified: String
          `,
          speaker: `
            uid: String
            name: String
            url: String
            slug: String
          `,
          button: `
            customText: String
            value: String
          `,
          eventLink: `
            customText: String
            value: String
          `,
        },
      },
    },

image

BUT if I change events: [event] to events: [events] and rename the event schema also to match, the images download — though I can then no longer access the event information through the conferences in GraphQL as they appear as null. The images appear under allImages?

image