Example of GraphQL querying a item with a relationship

Hi

I’ve looked everywhere but I can’t find an example on how to query a list of items, where each item has a field with a relation to another item using GraphQL. I am currently using the GraphiQL tool.

I want to see the relation item’s data nested. I see you’ve mentioned it can be done using GraphQL, but I can’t find an example.

Please help.

Thanks
Rudolph

Lets say you have two schemas:

  1. Category
    • name
    • posts (Reference to Posts)
  2. Posts
    • title

Then it would like this

{
   queryCategoryContents {
       id,
       data {
          name {
              iv
          },
          posts {
              id,
              data {
                title {
                  iv
               }
            }
        }
    }
}

Thanks, I’ve figured it out but for me it looked as follow:

{
   queryCategoryContents {
       id,
       data {
          name {
              iv
          },
          posts {
              iv {
                id,
                data {
                  title {
                      iv
                  }
                }
              }
        }
    }
}

yes, you are correct. Not easy to write these without intellisense.

Is this still working in 3.4.0? I cannot seem to find my relationship through the graphql api, the relationship property is simply not available in the graphql-api and the Dto’s, but it works through REST-api. Any ideas?

Sure, it has not been removed. Can you tell me more about your schema and the query you do?