Closed MariaSolOs closed 3 years ago
Same problem. If anyone succeed to get "go to definition" and "autocomplete", please let us know here :) Thanks!
So I was able to fix the issue with Codegen and using an introspection file for the schema. As a reference, here's a sketch of my project's structure:
|--graphql.config.js
|--package.json
|-- server
|--graphql
|--intro-schema.json
|--schema.ts
|-- codegen.yml
|-- client
|--src
|--graphql-api
Here's what worked for me:
npm i --save-dev @graphql-codegen/cli @graphql-codegen/introspection
.codegen.yml
file to your project. It doesn't need to be at the root, just make sure that the filepaths in this configuration file are correct. This is what I used:
overwrite: true
schema: './graphql/schema.ts'
watch: true
generates:
./graphql/intro-schema.json:
plugins:
- introspection
"scripts": {
...
"generate": "cd server && graphql-codegen --config codegen.yml"
},
graphql.config.js
file:
module.exports = {
schema: './server/graphql/intro-schema.json',
documents: ['./client/src/graphql-api/*.graphql']
}
And ta-da! It worked for me then :) (you may need to reload your window though).
Disclaimer 1: I didn't install Codegen
just to make the extension work. I use Typescript and so I wanted to use their tools to type my queries and mutations. I later saw that this extension also accepted introspection files and it did, so I successfully made it work with that.
Disclaimer 2: No, I don't work for Codegen
or anything like that. Just sharing what worked with me to the rest of the world <3
Thanks a lot @MariaSolOs for the detailed answer... but no luck for me :(
I'm using .graphqlrc.yml
config file, and even when setting the introspection .json file as schema value, vscode-graphql
doesn't give any extra hint. I guess I will just give up on go-to and auto-completion ^^
Actual Behavior
The extension successfully provides syntax highlighting but I'm not getting "go to" support or autocompletion.
Expected Behavior
The extension says guarantees "syntax highlighting, autocomplete suggestions, validation against schema, snippets and hover support".
Steps to Reproduce the Problem Or Description
In
.vscode/settings.json
, I included:and my graphql config file is
I'm sure the config file is found since I can see the Graphql button at the bottom when writing a gql string. However, there's no autocompletion at all and the "Execute Query" button on the client does nothing.
Specifications
Logs Of TS Server || GraphQL Language Service