Hi I wrote a PR for <GraphQL IDE Plugin> to help s...
# apollo-kotlin
s
Hi I wrote a PR for GraphQL IDE Plugin to help support operationName key which Apollo Client uses: https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/pull/596 and which many graphql servers will require for safelisted queries. I am not sure if you are in contact with the folks from that project but just wanted to bump it in any case. Also any feedback would be appreciated, thanks! I am using a forked version with my PR now in order to continue using IDE as a GQL Playground and make calls against federated server without context switching to apollo studio as suggested in https://www.apollographql.com/docs/kotlin/
👀 1
👍 1
m
Looks very cool, congrats 👏
K 1
I guess if you wanted to do everything super robust, you'd have to parse the GraphQL to extract the operationName instead of using regexes. Something like this is technically valid:
Copy code
query 
# comment
MyQuery
# other line
{
  field
}
But it's most likely not a very big issue and I'm not sure how easy it is to get the parsed query in the Idea plugin
s
Good point, yeah comments might definitely throw off the regex, of course hopefully those edge cases would be detected in development, and it is fully opt-in
👍 1
Ah yes, the parsed query, hmm, I could take a look, I'm not sure how difficult it would be to pull those from the build files exactly
m
Yep, most likely not a super big issue.
s
Thanks for the feedback Martin! Will try to clean it up further a bit and incorporate, like how difficult to use parsed version or maybe add regex to exclude comments altogether
m
It's mostly nitpicking at this point, I wouldn't worry too much about it. Worst case, if such thing happens you can parse the GraphQL with graphql-java. I think it is on the classpath there
mind blown 1
🙏 1
Something like
Copy code
Parser.parse("query MyQuery { field }").definitions.filterIsInstance<OperationDefinition>().first().name
🙌 1
s
Great suggestion, will take a look at the graphql-java api, have used KotlinPoet for parsing queries before agree this would be more robust approach