graphql-editor / graphql-zeus

GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native ( apollo compatible )
https://graphqleditor.com/docs/tools/zeus/index/
MIT License
1.93k stars 103 forks source link

Add * field #174

Open aexol opened 3 years ago

aexol commented 3 years ago

Add * field to construct a query with all scalar and enum fields.

enum Kind{
   FISH
   BIRD
}
type Animal{
  name: String!
  friends: [Animal!]!
  age: Int!
  kind: Kind!
}
type Query{
  animals: [Animal!]!
}
schema{
  query: Query
}
Gql.query({
  animals:{
    '*': true
  }
})

should result in

{
  animals{
    name
    age
    kind
  }
}
stewartmcgown commented 3 years ago

Is there a runtime way to just grab all the fields that a particular query path may have? That way you could introduce mixins as well, like an Omit(Queries.animal, ['age']).

elderapo commented 3 years ago

I suggest api similar to genql's one:

import { everything } from "./zeus-graphql"

Gql.query({
  animals:{
    ...everything,
    age: false,
  }
})