According to #7, queries in URL are a feature of GraphiQL and I've seen them in the wild, for example, in the Pokemon API. But I've also encountered several GraphiQL installations that don't have queries in URLs, e.g., Shopify's, MongoDB todo list, etc.
In https://github.com/graphql/graphiql/issues/703, it is mentioned that it's supported via graphiql-rails but is that the only way?
I'm just asking for clarification. On the APIs that support the ?query= URL links, I find it a bit suspicious that it's ? and not # (I'd imagine queries working purely client-side).
Hi @borekb, yes you can do this with GraphiQL. This example shows you how:
https://github.com/graphql/graphiql/blob/master/packages/graphiql-examples/cdn/index.html#L48-L55 https://github.com/graphql/graphiql/blob/2ea30c6029fd47107e85fb9d86459b02792ec705/packages/graphiql-examples/cdn/index.html#L48-L55
(The location of this example file moved when we turned this repo into a monorepo.)
Hope this helps!
(I'm assuming that the ?query= enables server-side rendering of GraphiQL, but I may be wrong on that.)
Thanks, @benjie!
@benjie that link 404's dunno if you could possibly edit?
@gilesbradshaw we moved the examples around.
You鈥檒l find an example of how to do this in packages/graphiql/resources/renderGraphiQL.js
I've updated my comment above to a link equivalent to what was there before (but permanent). Rikki's example is better; but it has also moved; it's now (permalink) here: