js-graphql-intellij-plugin
js-graphql-intellij-plugin copied to clipboard
Error on IntelliJ when "Run Introspection Query" and using wildcards on the schema config
Bug
IntelliJ popup the error Invalid "GraphQL configuration file" when clicking on the Run Introspection Query (the refresh icon on the side of the play)
Environment
Windows, IntelliJ IDEA 2023.1.2 (Community Edition) Folder Structure:
Backend/
graphql.config.yml
microservices
| microservice1
| | graphql
| | | microservice1.schema.graphqls
| | graphql-documents
| | | <docs>.graphql
| microservice2
| | graphql
| | | microservice2.schema.graphqls
| | graphql-documents:
| | | <docs>.graphql
bffs
| web-bff
| | graphql
| | | microservice1.schema.graphqls
| | graphql-documents
| | | <docs>.graphql
Config file
projects:
microservice1:
schema: 'microservices/microservice1/**/*.schema.graphqls'
documents: '**/graphql-documents/microservice1/*.graphql'
extensions:
endpoints:
orders: <MyDevEnv>
microservice2:
schema: 'microservices/microservice2/**/*.schema.graphqls'
documents: '**/graphql-documents/microservice2/*.graphql'
extensions:
endpoints:
orders: <MyDevEnv>
bffs:
schema: 'bffs/web-bff/**/*.schema.graphqls'
So, My microservices can communicate with each other, and the BFF communicates with both. The config is fine, it works, I have lint on the proper documents matching the correct service they call, and I can test the query and mutations in development against my dev server.
The annoying problem is that I get a popup on the IDE when I run the refresh saying
Please provide a valid path to schema in the config file. The first schema pattern should contain the correct path to a file in the file system. Provided: 'microservices/microservice1/**/*.schema.graphqls'.
If I go there on the config file and replace the schema for the complete path (without wildcards) on the schema it works just fine.
It seems that glob pattern is simply not working. This .graphql.config.yml
returns the same error when introspecting:
schema: './adapter/web/**/*.graphqls'
extensions:
endpoints:
local:
url: http://localhost:8910/graphql
headers:
Authorization: Bearer ${TOKEN}
all my .graphqls
files are under adapter/web/src/main/resources/schemas/
. using
schema: './adapter/web/src/main/resources/scehma/*.graphqls'
is not working as well
I was afraid that it would cause issues like that, probably I should change the error message and add a doc reference.
Just curious from the UX perspective, what do you expect to happen when you run an introspection query like that? It tries to save a downloaded introspection schema as a file to your project, so you should provide some real path in the file system. ./adapter/web/**/*.graphqls
is not valid, ./adapter/web/schema.graphqls
will work. More details are here. In theory, I can try to generate a path from the glob, removing invalid chars and using some default name for the file, but I'm not sure if it's a good solution.
If you don't need to store a schema in the project, you can just use a URL in the schema
key and run an introspection query (https://github.com/JetBrains/js-graphql-intellij-plugin#remote-schemas):
schema: https://my.api.com/graphql
That's a new way to work with remote schemas which was introduced after migration to a new graphql-config standard.