graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
16.07k stars 1.72k forks source link

Plugin: keyboard shortcut to add all fields #661

Open axos88 opened 6 years ago

axos88 commented 6 years ago

Related: https://github.com/graphql/graphiql/issues/75

I would love to see a button, or a key combination that will add/autocomplete all direct fields of the current object. Complex fields will be autocompleted to {}, that will need to be manually fileld out.

Example:

Type Person with fields id, name, groups, teams
Type Group with fields id, name, people
Type Teams with fields id, name, people

Typing

query { 
  people { 
    <MAGIC KEY COMBINATRION>
  } 
}

becomes

query { 
  people { 
    id
    name
    groups(page: null , page_size: null) {  
    }
    teams(page: null , page_size: null) {  
    }
  } 
}

Also plus if the complex subtypes are added at the end

axos88 commented 6 years ago

Another possibility is to have an "add all" in the autocomplete dropdown.

kevinsimper commented 6 years ago

@axos88 That would be a cool feature and something I have thought of myself!

imolorhe commented 6 years ago

https://github.com/imolorhe/altair

acao commented 5 years ago

this would be cool! Altair is a great tool that uses our codemirror-graphql mode and accomplishes this readily.

FWIW, there is a shortcut for automatically adding all required fields for an object type. just type in the name of the field, and before adding brackets, just hit enter, and youll see it automatically add all the required fields for that object. voila!

imolorhe commented 5 years ago

@FluorescentHallucinogen has some nice ideas on the UX for this too!

FluorescentHallucinogen commented 5 years ago

@FluorescentHallucinogen has some nice ideas on the UX for this too!

Yep, see https://github.com/prisma/graphql-playground/issues/683#issuecomment-464465807 (first iteration) https://github.com/prisma/graphql-playground/issues/683#issuecomment-464845224 (improved) https://github.com/prisma/graphql-playground/issues/683#issuecomment-477032683 (final vision)

The only thing that may not clear from my last image (final vision) is the "Insert all fields" and "Insert required fields" items are clickable, aren't just static tips.

Please also take a look at https://github.com/imolorhe/altair/issues/753.