Skip to content

Instantly share code, notes, and snippets.

@StrongerMyself
Created June 18, 2019 12:12
Show Gist options
  • Save StrongerMyself/219c7968fefa59785a4d8f24606a4d09 to your computer and use it in GitHub Desktop.
Save StrongerMyself/219c7968fefa59785a4d8f24606a4d09 to your computer and use it in GitHub Desktop.
Idea graphql client API
var api = new GraphQL(path, {
method: 'POST', // POST by default.
headers: {
'Access-Token': 'some-access-token'
},
query: {
tags: 'tags { ...tag }',
tag: 'tag { ...tag }',
},
mutation: {
tag: 'tag(input: $input, id: $id) { ...tag }',
},
subscribe: {
tag: 'tag(input: $input, id: $id) { ...tag }',
},
fragment: {
tag: 'on Tag { id name description }',
}
})
api.state
api.req().then()
api.req(name).then()
let field = api.getState('field.key')
var entity = api.entity(initial, name, schema, fragment)
entity.state
entity.args
entity.req().then()
let field = entity.getState('field.key')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment