0.0.2 • Published 5 months ago
@fxhash/gql-client v0.0.2
@fxhash/gql-client
The gql-client provides a simple GraphQL client which can be used with @fxhash/gql for running typed operations. The client works on front-ends and back-ends, although using a different package for front-end application would be best as this one doesn't come with the best-in-class toolkit for front-end applications.
This package wraps @urql/core by providing some default config working well with our stack.
Note
- The client will automatically add the
x-hasura-admin-secrethttp header if the env variableHASURA_ADMIN_SECRETis defined.- The client will point to the hasura api scoped to the environment in which it's executed, based on
FXHASH_ENVenv variable (it uses the generic@fxhash/configpackage for such purpose)
Usage
Install
pnpm add -E @fxhash/gql-clientUsage
import { gqlClient } from "@fxhash/gql-client"
// making a query
const { data, error } = await gqlClient.query(...)Client instanciation
If needed, instanciating a client with custom options is available. The client will not automatically add the x-hasura-admin-secret header, it must be passed with the hasuraAdminSecret option.
import { createGqlClient } from "@fxhash/gql-client"
const client = createGqlClient({
//... custom options here
})