4.0.0 • Published 9 months ago

@taskless/graphinql v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

A super-lightweight GraphQL client built on cross-fetch. As few dependencies as possible, works in the browser and server. Specifically built to work with strings and avoid a dependency on graphql / graphql-tag so you can keep your codebase light. In short, the best parts of graphql-request without the graphql dependency, but without losing the ability to type your requests and responses.

  • ✅ Queries, Mutations, Introspection
  • ✅ Custom headers per request or shared via new GraphQLClient()
  • ✅ Typed responses and variables
  • ❌ Typed GraphQL Document Node (exposing these types would force graphql to be a dependency, and risks the "multiple GraphQL" bug even for types-only support)
    • Note: If you need the Typed Document Node, you should use the excellent graphql-request library
  • ❌ Subscriptions (operates over https fetch)

BREAKING CHANGE (4.x)

:warning: With node 18 providing a What-WG compatible fetch, version 4.0 of graphinql no longer provides a fetch by default nor includes p-retry. If you need these features, you can provide them yourself, via the new fetch option.

Usage

import { GraphQLClient, request } from "@taskless/graphinql";

// as an object
const client = new GraphQLClient(endpoint, options);
const { data, error } = await client.request<TReturnType, TVariables>(
  stringDocument,
  {
    // variables
  },
  {
    // options
  }
);

// or as a one-off
request<TReturnType, TVariables>(endpoint, stringDocument, variables, options);
  • endpoint Your GraphQL endpoint
  • stringDocument A GraphQL query, as a string
  • variables (optional) GraphQL Variables if applicable
  • options (optional) A set of GraphQL Client options, provided as an object
    • options.headers<HeadersInit> (optional) A Headers compatible object, specifying headers to include with the request
    • options.fetch<typeof fetch> (optional) A What-WG compatible fetch interface

Additional Examples

About the Name

This library was originally built on phin before migrating to a What-WG fetch solution.

Contributors

All Contributors

License

The source code in this repository is made available under the MIT license.

3.7.2

9 months ago

4.0.0

9 months ago

3.7.1

11 months ago

3.7.0

11 months ago

3.6.2

1 year ago

3.4.0

2 years ago

3.3.1

2 years ago

3.3.0

2 years ago

3.3.5

2 years ago

3.6.1

2 years ago

3.3.4

2 years ago

3.6.0

2 years ago

3.4.2

2 years ago

3.3.3

2 years ago

3.5.0

2 years ago

3.4.1

2 years ago

3.3.2

2 years ago

3.2.1

2 years ago

3.1.2

2 years ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

3.0.0-next.4

2 years ago

3.0.0-next.0

2 years ago