Closed nanafan93 closed 1 year ago
Hi! AFAIU you're trying to execute a type definition, instead of a query, it doesn't work that way. https://stackoverflow.com/questions/59417171/whats-difference-between-schema-and-documents-in-graphql
That would be a proper query for your schema:
query MyQuery {
hello {
a
b
}
}
To execute a query directly from the editor, place the caret on the query definition, and run the Execute Query action from the toolbar either manually or by using the Ctrl/Cmd + Enter hotkey. The query will be sent to a selected endpoint in the toolbar.
If your query has variables, you can open a dedicated variables editor using the Toggle Variables Editor action on the same toolbar. You can then provide the variables in JSON format.
Alternatively, you can create a GraphQL scratch file and use it as a playground for sending queries. The easiest way to create such a file and associate it with the correct GraphQL config is to use the GraphQL tool window. Simply double-click on the endpoint node and choose New GraphQL Scratch File.
I think I misunderstood the docs. What does editor really mean here ? I mean I could get a query to work from the scratch pad but what is the other method described in the first paragraph?
Validation error of type NonExecutableDefinition: The Blah definition is not executable. Validation error of type NonExecutableDefinition: The Query definition is not executable.
these errors mean that you put a caret on a type definition and ran an action to execute a query. That doesn't work in GraphQL.
What you mentioned here is not a "query", it's a type definition, you can't send it to the server. Or maybe I don't understand your question 🤷♂️
type Blah {
a:String!
b: Int!
}
extend type Query {
hello: Blah!
}
Yes I understand that and you are correct. What I am asking is that is the meaning of "editor" in the first paragraph above. Is there any other way to run a query apart from writing it out in the scratch pad which I am not aware of ?
You can put a caret right into the query in the editor (an outline around a query will appear), select an endpoint in the toolbar above, and press on the green arrow button or ctrl + enter
.
My project structure is as shown below. Basically I want to start off with an empty schema and then "fill in" the types and extend the operations from all other files. I would prefer to not change my structure.
/graphql
The schema.graphqls file is defined as
and then in each of the files in the directories I extend the query/mutation field arbitrarily and define new types as well. For example
A.graphls would be something like
My problem is whenever I place the caret on any of these "extended" query definitions, it refuses to execute the query. Also, it tries to query starting from the top of the file resulting in errors like.
Validation error of type NonExecutableDefinition: The Blah definition is not executable. Validation error of type NonExecutableDefinition: The Query definition is not executable.
How do I get around this ?