JSPM

gqlgen-cli

4.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q40801F
  • License MIT

Generate a client sdk from your GraphQl API

Package Exports

  • gqlgen-cli
  • gqlgen-cli/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gqlgen-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme





Type safe Graphql query builder

Write Graphql queries with type validation and auto-completion with batteries included



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

Features

  • Type completion
  • Type validation
  • Easily fetch all fields in a type
  • Support subscription ( ws, graphql-ws, observable, etc )
  • Built in file upload support
  • Graphql Client built in
  • Works with any client
  • Works in node and the browser
  • Built in Axios Client, and exported to extend with interceptors.
  • Client Operation support for Axios configuration, such as headers, timeout, cancelToken, abortSignal, etc.
  • Support batching queries
  • Consistent response format { data, errors, extensions }

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.

Example usage

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
    }
  }
}

Licensed under MIT.