I tried to use JetBrains' GraphQL plugin in Intell...
# graphql-kotlin
c
I tried to use JetBrains' GraphQL plugin in IntelliJ IDEA on the Shopify GraphQL API, but it errored out. I've written about it here https://github.com/JetBrains/js-graphql-intellij-plugin/issues/749 -- maybe anyone here recognizes this error, or knows what i can try to fix it? Thanks in advance.
b
Should
<https://shopify.dev/admin-graphql-direct-proxy/2024-07>
be the URL of your GraphQL endpoint? It seems to lead to a 404.
c
but it works! i think a 404 is normal when pointing a browser on a graphql endpoint
i managed to make graphql request to the endpoint, i just dont get the syntax highlighting + error highlighting + autocomplete to work
b
Ah you're right the url is correct indeed. Well it looks like a bug in the plugin. In the meantime you can fetch the schema with another tool and put it in your project manually.
c
I load the schema with the
{ id = "com.expediagroup.graphql", version = "8.8.1" }
Gradle plugin's
graphqlIntrospectSchema
task. This puts it in the
build
folder. But all GraphQL syntax highlighting, error highlighting and autocompletion is broken.
b
you should put it in a folder that's consistent with what you define in your
graphql.config.yml
file
so basically
schema: path/to/your/schema.graphqls
c
I tried that, but it did not matter for the outcomes.
b
weird!
c
Either the schema points to an endpoint for introspection, or it points to a local file.
b
I'd expect it to work fine when pointing to the local file
what does the GraphQL tool window say?
c
I'm changing it as we speak...
👍 1
so changed the build.gradle.kts file to point to the introspection endpoint of Shopify, then i used ``graphqlIntrospectSchema` to download the schema. i confirmed it is in build/schema.graphql
Opening the schema file show errors all over the place (because the intellij plugin is not working well)
graphql.config.yml contains:
image.png
test query shows errors:
image.png
b
can you show the GraphQL toolwindow
c
running the testQuery (by executing the program) works though
b
not sure if that's the issue but do you need quotes around the path maybe?
c
image.png
b
yeah '8 types' etc. is wrong
c
this all looks fine (i pressed the "Restart Schema Discovery" (recycle icon) button)
yes, 8 types is wrong
"not sure if that's the issue but do you need quotes around the path maybe?", that's why I got it to work with the pokemon API, so I could determine that all works well when not using the Shopify API
b
have you tried with quotes though? 🙂
schema: 'build/schema.graphql'
also.... this is probably not the issue, but just to try, can you move it to a different folder than
build
? Sometimes
build
is ignored by the IDE, files inside it are not indexed, etc. Put it in
src/graphql
for instance
c
I'll try... Thanks for the help btw, much appreciated.
The main thing is: it works this way for Pokemon.
b
yeah the plugin seems to have an issue interpreting the introspection result for the Shopify schema (The pokemon schema is probably much simpler)
This seems to be a recent issue too, because I couldn't repro with an older version of the plugin
c
i also tried to use an older version, but when going back to older version I expect I also have to use an older version of intellij at some point
what version of the plugin works for you? then I can try that as well here...
wow...
b
exactly that's when testing with an old version of the IDE, so not practical
c
it seems you hunch was correct!
b
ah great 🎉
c
image.png
i've put it in the root of the project and pointed the graphql.config.yml to it (wiht quotes), pressed the recycle icon in the GraphQL pane and BOOOOM!
b
nice 🙂
c
the query was still showing errors (red) all over, but different errors now... i'm invalidating caches, etc, and see if I can get it to work..
invalidating caches helped
image.png
👍 1
happy camper right here! thanks a lot for the wisdom. i was stuck on this for hours.
b
Happy to help!
c
I'll document this in the issue I raised for this and close it
b
wait no you should still keep the issue open, as it's still a bug that the introspection doesn't work
c
and do I get correctly you use apollo yourself?
because I went with
graphq-kotlin
(I dont need multiplatform, JVM is enough(
b
I work at Apollo actually (on Apollo Kotlin). We actually have an IDE plugin, which currently depends on the GraphQL plugin.
are you building a client or backend app?
c
yes I saw that, it was going to be the next thing i'd try "go the apollo route"
im building something that pulls data from shopify, from a server-side (JVM) application that also provides users with a portal.
b
I see. Well, if all you need is a GraphQL client, Apollo Kotlin may be a good fit. Its + is that it generate models from your queries, so everything is strongly typed.
Most of the users are on Android, but it works on JVM as well.
GraphQL Kotlin is probably fine too! I've only used it on the backend, not on the client side of things, so I'm not too sure how it works there.
c
i though this my current approach also did some model generation... the
graphqlGenerateClient
task generates this for me:
b
ah there you go, didn't know Graphql Kotlin had that feature!
c
"Most of the users are on Android, but it works on JVM as well." yes because you allow for multi platform projects, where the
graphql-kotlin
approach only works on the JVM
👍 1