Graphiql: Autocomplete for required variables

Created on 9 May 2017  Â·  10Comments  Â·  Source: graphql/graphiql

I've just created a createUser mutation and there are about 30 potential fields, around 20 are required.

As I type I get told that I'm missing lots of required fields like so:

screenshot 2017-05-09 11 48 22

I think it'd be nice for autocomplete to add all of the required input fields so you can change booleans and fill in strings really quick. Right now it's a case of looking at the error tooltip and adding each of them manually

enhancement help wanted

Most helpful comment

@intellix eek that's painful. I can think of a couple of ways to help with this case - one is to add a button that fills all required fields with some temporary values (e.g. "" for strings, false for booleans, {} for objects, and etc).

Another is to automatically suggest variables when the query gets run, inferring from the default values for input types from your schema. Do your required fields have default values?

All 10 comments

@intellix eek that's painful. I can think of a couple of ways to help with this case - one is to add a button that fills all required fields with some temporary values (e.g. "" for strings, false for booleans, {} for objects, and etc).

Another is to automatically suggest variables when the query gets run, inferring from the default values for input types from your schema. Do your required fields have default values?

Haven't got default values, but the above sounds good to me :)

@intellix eek that's painful. I can think of a couple of ways to help with this case - one is to add a button that fills all required fields with some temporary values (e.g. "" for strings, false for booleans, {} for objects, and etc).

That sounds rad!

I'd love for a contribution here ;)

No updates in a couple of months. Has any work been done on this? Seems like a reasonable convenience that should be built-in. I haven't had situations that deal with that many nodes but even just a handful of errors in this trivial case are a bit of a nuisance to me.

Has any work been done on this?

I'm not aware of any work that's been done on it. It has the "help wanted" tag on it, so hopefully somebody that wants this enhancement will step forward with a PR.

For queries, I am observing the exact opposite behavior of what's been requested here. That is, if I mark a field as required=True, then it does NOT appear in the auto-complete for a query of a type, while fields with required=False do appear.

Is this expected behavior? I expected the opposite of what's happening for me, i.e. to include _only_ the required fields in auto-complete of a query.

this works now, i'm not sure when the feature was added, but when you type out a field name and hit enter, if it has required fields they will be automatically added.

@acao, which version is this? Can only see autocomplete field names not values.

Think autocomplete configuration should be revisited to include more options for newbies (like me):
autocomplete.braces (complex types always need braces right?)
autocomplete.default.values (also inserts a default "", number or anything else)
autocomplete.mandatory.fields (if there are a ton of fields, it takes a long time)
autocomplete.mutation.constructor.arguments (complex types in mutation arguments never show any additional auto completion) https://medium.com/atheros/json-as-an-argument-for-graphql-mutations-and-queries-3cd06d252a04 is an example with complex input type and there is no additional help after typing mutation input.

Using Apollo Server Express with GraphQL playground
├─ [email protected]
│ ├─ @apollographql/graphql-playground-html@^1.6.6

try graphiql 0.17.5
all graphql web IDE or electron clients use codemirror-graphql here in our repository, as far as i know

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sulliwane picture sulliwane  Â·  29Comments

OlegIlyenko picture OlegIlyenko  Â·  17Comments

Glavin001 picture Glavin001  Â·  10Comments

divyenduz picture divyenduz  Â·  21Comments

songololo picture songololo  Â·  25Comments