@autoinvent/magql-query
v0.4.0
Published
Query builder for communicating with magql backend.
Downloads
26
Keywords
Readme
magql-query
A library for building and sending queries to a magql-generated GraphQL API.
Docs
Installation
yarn add @autoinvent/magql-query
With npm:
npm install --save @autoinvent/magql-query
Usage
IMPORTANT: This package requires the usage of conveyor-schema for creating the SchemaBuilder object to pass to the MagqlQuery constructor.
Example
import { MagqlQuery } from '@autoinvent/magql-query'
import { SchemaBuilder } from '@autoinvent/conveyor-schema'
// would also require a schema.mergeSchema(remoteSchema) with the remote (backend) schema in practice
const schema = new SchemaBuilder(schema)
const endpoint = 'your/graphql/api/endpoint'
const magqlQuery = new MagqlQuery({ schema, endpoint })
// see docs for method options
magqlQuery.buildQuery({ ... })
magqlQuery.sendRequest({ ... }).then(({ data, error }) => {/* do something */})
magqlQuery.buildAndSendRequest({ ... }).then({ data, error }) => {/* do something */})