js-graphql-intellij-plugin
js-graphql-intellij-plugin copied to clipboard
A schema should have a 'query' operation defined, but Query type is defined.
Hello, I am currently having a problem with GraphQL plugin for PyCharm.
In GraphQL window in PyCharm I get a Schema error A schema should have a 'query' operation defined
. Introspection works and the generated by the plugin schema has type Query defined! wtf?
I am using GraphQL 3.1.2 plugin in PycharmProfessional. Here is .graphqlconfig file content in case it matters:
{
"name": "Untitled GraphQL Schema",
"schemaPath": "schema.graphql",
"includes" : ["./src/**/*.graphql"],
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:7777/graphql/",
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": true
}
}
}
}
Expected behaviour is that the graphql plugin detects the Query type that it itself generated.
Screenshots
Version and Environment Details Operation system: Linux Mint 20.3 Cinnamon IDE name and version: PyCharm Professional 2021.3.2 Plugin version: 3.1.2
If you need more info please let me know. How do I solve this problem? Am I missing something?
Where is the schema section of your graphql file (starting at line 1)? It should look like
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
or subscription: null if your API doesn't support notifications.
I'm just guessing, but the error sounds like it's complaining about a missing operation, not a missing type definition.
@segfaultDelirium hey, sorry for the late response. It looks like the GraphQL file type wasn't recognized by the IDE for some reason, an opened file has the wrong icon in the tab header. I fixed an issue with file types in the past few releases, so it possibly could be fixed already. If it's still an issue please ping me.
@davaya it's not required to specify a schema explicitly if your operations have default names like Query
, Mutation
, and Subscription
. The plugin should respect that naming convention and it's expected to work out of the box.
@segfaultDelirium came across same issues, these two fixes solved it
- check if your "name" and "endpoints" match e.g.:
"name": "SOME_NAME", <---- need to match
....
"extensions": {
"endpoints": {
"SOME_NAME": { <---- need to match
.....
},
}
}
}
}
- simply delete generated
schema.graphql
file and generate it from scratch