question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

graphiql doesn't make use of `variables` search param

See original GitHub issue

Editing “Query Variables” in graphiql:

Screenshot 2019-12-18 at 16 49 14

Updates the variables search param (for example https://711808k40x.sse.codesandbox.io/___graphql?variables={ “variablesFromParam”%3Atrue } ), but loading this url, doesn’t make use of passed variables and uses values stored in localStorage

We are missing variables prop in https://github.com/gatsbyjs/gatsby/blob/69ecf6a534b2be20e3b1ffe0b694ea677b68bb66/packages/gatsby-graphiql-explorer/src/app/app.js#L322-L330

Per graphiql documentation ( https://www.npmjs.com/package/graphiql ):

variables: an optional GraphQL string to use as the initial displayed query variables, if undefined is provided, the stored variables will be used.

Work to be done

Check how we set initial query: https://github.com/gatsbyjs/gatsby/blob/69ecf6a534b2be20e3b1ffe0b694ea677b68bb66/packages/gatsby-graphiql-explorer/src/app/app.js#L83-L91 and implement analogous logic for variables, and use that to pass variables prop to Graphiql element

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
piehcommented, Feb 3, 2020

That localstorage key is used internally by graphiql package - that’s how graphiql stores and restores variables when you refresh. We want to first use params from url, if those are not set, use localstorage and if that is not set use empty object or nothing

0reactions
dvrylccommented, Feb 3, 2020

I have a version of this working, just wanted to check if @peaonunes is still working on it?

Also @pieh, seems like there’s a key graphiql:variables in localStorage, do you know where that’s set and/or used?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing Arguments - GraphQL
Using $dice and $sides as variables in GraphQL means we don't have to worry about escaping on the client side. With basic types...
Read more >
How to use GraphQL variables to give queries type safety
In an HTTP POST request to the GraphQL API, variables are passed to the GraphQL request as a separate property inside the body...
Read more >
How to Filter and Search using Variables in Apollo Client
You know how to query data from Apollo Client using the useQuery hook, but what about searching and filtering it? How does that...
Read more >
Why does graphql not accept the parameters that I pass in the ...
Your mutation doesn't seem to be in line with the schema documentation you have posted. The schema shows that the createPost mutation takes ......
Read more >
Designing a URL-based query syntax for GraphQL
Default variable values can be defined like any variable: via a URL param. The on element is not needed since we can instead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found