graphiql icon indicating copy to clipboard operation
graphiql copied to clipboard

Plugin: keyboard shortcut to add all fields

Open axos88 opened this issue 7 years ago • 6 comments

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 avatar Feb 15 '18 14:02 axos88

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

axos88 avatar Feb 15 '18 14:02 axos88

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

kevinsimper avatar Feb 22 '18 09:02 kevinsimper

https://github.com/imolorhe/altair

imolorhe avatar Mar 10 '18 13:03 imolorhe

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!

acao avatar Jun 25 '19 02:06 acao

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

imolorhe avatar Jun 25 '19 06:06 imolorhe

@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.

FluorescentHallucinogen avatar Jun 26 '19 09:06 FluorescentHallucinogen