graphqlkeystonejs

Error in GraphQL where clause on Keystone 6


I am using Keystone 6, which ships with the latest version of Apollo. Normally, with GraphQL, we could insert a simple where clause with the following statement:

query {
  posts ( where: { title: "test" } ) {
    title
  }
}

However, upon trying this with Apollo Studio, I get the following error:

Expected value of type "StringFilter", found "test".

I have tried various ways to fix this but nothing seems to work. Can any of you help out?

Thank you.


Solution

  • Ah, I know that error. Keystone 6 is in a pre-release period and there are still occasional breaking changes to the API. Recently some changes to the structure of the GraphQL schema were released. Running the older style of queries on the new GraphQL schema will produce the error you're seeing.

    In this case, the query can be rewritten as:

    query {
      posts ( where: { title: { equals: "test" } } ) {
        title
      }
    }
    

    The GraphQL Queries docs have more usage instructions and examples. There's also an upgrade guide that specifically covers all the changes you'll need to make to your queries from before this upgrade.