Schema validation of .graphql queries in VSCode (edited title)


I’ve managed to get a good setup with TS code generation based on .graphql query files. But I’ve been wondering if it’s somehow possible to get autocompletion and validation of the queries in these .graphql files when writing them?

I’ve looked into using the introspection query to generate a schema.graphql to then use with a Graphql vs-code extension but it doesn’t seem that simple.

Anyone have any clues as to how to approach this? It feels a bit clunky to have to write all queries in the CDA Playground and then copy paste into vs-code.

Hi @emil.hernqvist!

With our demo project at least, I was able to get this working using one of the extensions: GraphQL for VSCode. There are several of them but this one seems to work:

All I had to do with install the extension, edit /graphql.config.yml with my CDA read-only API token, and then close and reopen the project (important).

Please let me know if that works?

1 Like

Hi and thanks for the reply! I actually managed to get it working later after posting this, in more or less the way you suggested. So for anyone who stumbles upon this, do like above!

This might be something that would be neat to have documented, since this raises the devX quite a bit?

1 Like

That’s a good idea! We’re in the process of updating some docs, and I’ll add it to the list!

Was there a particular plug-in you liked more than the others for any reason?

Sweet, thanks! I found that GraphQL.vscode-graphql which is the most popular one had the best support and API.

1 Like

Great, thanks. I have this in my backlog of documentation to add, hopefully soon :slight_smile: