js-graphql-intellij-plugin
js-graphql-intellij-plugin copied to clipboard
A schema MUST have a 'query' operation defined Error. But I have type Query in my schema.
I have added my schema to a .graphql file in my main project directory. I now get this error:
This is very weird because I do have a type Query {}
in my .graphql file with multiple queries in there. When I copied the Query type into an empty .graphql file and I changed all the return types to strings I did not get the error anymore.
To Reproduce
I don't really know how you could reproduce this I don't want really share my schema.
Expected behavior I don't expect a 'A schema MUST have a 'query' operation defined' error to pop up when there is a type Query in the schema
Version and Environment Details Operation system: Win 10 IDE name and version: Webstorm 2020.3.2 Plugin version: 2.9.1
Same here
Please could you bubble up the error message from parsing the file? At least if we know a line number of the .graphql that is causing the issue, I could open a better issue with a more exact feature request.
Sorry but I am not sure what you mean with bubble up the error message from parsing the file.
I feel the graphql parser used from your plugin is not liking my schema.graphql (>100k lines). I've tried snipping off random bits in an attempt to narrow down what is causing the issue (for example enum's), but no luck so far. What I ideally need is to see the inner exception - something like "Unexpected token on line 178937".
It feels like the parse happened inside a try/catch block, and it silently failed, causing the schema to have no query (the error I see).
@binary64 I ran into the same error as well. Do you use a schema inside the node_modules
folder?
I struggled with the same error for a while. Then I accidentally deleted the project from IntelliJ and removed all hidden IDE subfolders, and when I re-added the same project folder back to WebStorm the plugin worked perfectly again. Worth a try :)
Unfortunately, this is a common error that occurs when the schema could not be built for some reason. I've improved error handling and logging in the upcoming version that I'll release soon.
@vepanimas
I experience this issue on Webstorm 2021.3.2 and plugin version 3.1.2, even with the simplest example of relay-schema.graphql and .graphqlconfig:
@goktugerce Temporary solution is install plugin version 3.0.0 from https://plugins.jetbrains.com/plugin/8097-graphql/versions
@Mozzarella123 I tried, and it didn't help.
Same Problem. Schema is generated but Schema discovery summary says "schema is empty". Any help? Webstorm 2022.2.2 and GraphQl 3.3.0
I'm also bumping into this with a small schema:
# This file was generated based on ".graphqlconfig". Do not edit manually.
schema {
query: Query
}
interface ContentNode {
_meta: ContentNodeMetaData
rawJson: ContentItemJson
rawProperty(propertyName: String!): JSON
}
type ContentItemJson {
content: JSON
}
type ContentNodeMetaData {
deliveryId: String!
deliveryKey: String
name: String
schema: String!
}
type PageInfo {
endCursor: String
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
}
type Query {
allStaticPage(after: String, before: String, first: Int, last: Int): StaticPageConnection
allWebConfig(after: String, before: String, first: Int, last: Int): WebConfigConnection
contentNode(deliveryId: String, deliveryKey: String): ContentNode
staticPage(deliveryId: String, deliveryKey: String): StaticPage
webConfig(deliveryId: String, deliveryKey: String): WebConfig
}
type StaticPage implements ContentNode {
_meta: ContentNodeMetaData
articleContent: String
rawJson: ContentItemJson
rawProperty(propertyName: String!): JSON
slug: String
title: String
}
type StaticPageConnection {
edges: [StaticPageEdge]!
pageInfo: PageInfo!
}
type StaticPageEdge {
cursor: String!
node: StaticPage
}
type WebConfig implements ContentNode {
_meta: ContentNodeMetaData
rawJson: ContentItemJson
rawProperty(propertyName: String!): JSON
social: WebConfigSocial
}
type WebConfigConnection {
edges: [WebConfigEdge]!
pageInfo: PageInfo!
}
type WebConfigEdge {
cursor: String!
node: WebConfig
}
type WebConfigSocial {
facebook: String
twitter: String
}
"A JSON scalar"
scalar JSON
Corresponding .graphqlconfig:
{
"name": "GraphQL Schema",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"GraphQL Schema": {
"url": "https://<redacted>/graphql",
"headers": {
"X-Src-Host": "<redacted>"
},
"introspect": false
}
}
}
}
Error: A schema should have a 'query' operation defined
with plugin version 3.3.0
.
In my case, .graphql files were not associated with the .graphql file type.
Once I associated them (right-click on the unassociated example.graphql file) I refreshed the .graphqlconfig and re-fetched the introspection schema.
After that everything started to work as before.
![Xnapper-2023-01-31-13 22 13](https://user-images.githubusercontent.com/1639717/215760649-b15859a1-dbee-4da9-95f5-d00d9285e63f.png)
![Xnapper-2023-01-31-13 22 49](https://user-images.githubusercontent.com/1639717/215760655-2fe27c78-6c0f-42df-b132-84b995312dc4.png)