Graphiql: Plugin: auto-exclude unused variables from request

Created on 12 Oct 2019  路  4Comments  路  Source: graphql/graphiql

Right now GraphiQL will send the full value of the variables form, even if they query itself doesn't make use of them. This can be pretty cumbersome on e.g. Hasura where it'll refuse to run a query if it sees unexpected variables present, but you might have multiple operations with their own variables and you want to be able to run them in quick succession.

It'd be nice if, just like auto-setting an operationName, GraphiQL plucked only the relevant variables to be sent to the server.

potential plugin

Most helpful comment

I worry that this is too much in the realms of "magic." If the user enters variables into the variable editor and they are not sent to the server I think that could be very confusing (and misleading when they copy those same variables into their application and then it doesn't work even though it worked in GraphiQL). As such, I think this would make sense for an opt-in plugin but should not be part of the core implementation.

All 4 comments

I worry that this is too much in the realms of "magic." If the user enters variables into the variable editor and they are not sent to the server I think that could be very confusing (and misleading when they copy those same variables into their application and then it doesn't work even though it worked in GraphiQL). As such, I think this would make sense for an opt-in plugin but should not be part of the core implementation.

@sgrove - thank you for the suggestion. I agree with Benjie, that at this time it is probably too much added magic. I believe that the spec does allow you to pass additional (unused) variables in the request. Would it maybe be possible to raise this issue with Hasura? :)

Agreed this would be great for a plugin, not what we'd expect as spec behavior

What might help your situation @sgrove is possibly a way to re-use variables? That would be a really cool plugin.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pleunv picture pleunv  路  5Comments

Nishchit14 picture Nishchit14  路  5Comments

sereanaseim picture sereanaseim  路  5Comments

lielran picture lielran  路  3Comments

samrae7 picture samrae7  路  3Comments