Find more server-client examples in the examples repo You will find multiple examples with different tools of building schema, query, mutation, websocket subscriptions and more.
First generate your client executing
npm i -D @gqlts/cli # cli to generate the client code
npm i @gqlts/runtime graphql # runtime dependencies
gqlts --schema ./schema.graphql --output ./generated
Then you can use your client as follows
import { createClient, everything } from './generated'
const client = createClient()
client
.query({
countries: {
name: true,
code: true,
nestedField: {
...everything, // same as __scalar: true
},
},
})
.then(console.log)
The code above will fetch the graphql query below
query {
countries {
name
code
nestedField {
scalarField1
scalarField2
}
}
}
This package is forked version from genql
It has been updated, fixed few bugs, actively adding features and updated dependencies and codebase to the latest packages
Read the quick start guide to generate a client locally
Author: meabed
Source Code: https://github.com/meabed/gqlts
License: MIT license