Help with GraphQL and Reference fields

I am able to query pages with GraphiQL. I’ve never used GraphQL so I’m super green here. I have few issues.

  1. I don’t know how to query the “pageComponents”
  2. Using PostMan I see I get back the ID’s for each component but I’m not sure how to reach that content
  3. Did I mention I’m new to GraphQL?

This is the PostMan JSON

"data": { "title": { "iv": "Home" }, "slug": { "iv": "home" }, "pageComponents": { "iv": [ "58c04b97-c561-40b4-a09b-0f6baec71c0a", "cf3c1760-363d-480b-be8a-2615ba005d19", "de36a290-4423-4473-b93c-c146c17fe596" ] } }

This is as far as I have gotten with my Query

query{
  findPagesContent(id:"xxxxxx", version:x) {
    id,
    data: flatData{
      title,
      slug,
         pageComponents (Error's here the only option I get here is __typename)
    }
  }
}

Thats weird, you should get fields like id, lastModified and so on. If you use the cloud: Please give me more information like the app name, otherwise a backup of your Mongod database would help.

Hi @Sebastian the app name is funtimesplaytime. I can provide a Mongod back-up also.

Where should I send the DB backup?

Upload it to a cloud provider and send me the link via PM.

When your reference allows multiple schemas you have to define the type:

query {
  queryPagesContents {
    id,
    flatData {
      pageComponents {
        ...on Content {
          id
        },
        ...on Header {
          flatData {
            title
          }
        }
        __typename
      }
    }
  }
}

See: https://graphql.org/learn/queries/#meta-fields

I managed to get things working, but I had to demolish my schema’s and start again. It ended up being a good thing as I was able to simplify things.

Thanks for all the help.

1 Like