npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@taskless/graphinql

v4.0.0

Published

A minimalist GraphQL client based on phin

Downloads

12

Readme

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.