jacob-ebey / tiny-graphql

A tiny GraphQL suite for making your dev and user experience better than ever.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tiny GraphQL

A tiny GraphQL client for making your dev and user experience better than ever.

Truly tiny

Core

https://www.npmjs.com/package/@tiny-graphql/core

core

Everything you need to get going query for data and perform mutations lives in it's own package.

Cache

https://www.npmjs.com/package/@tiny-graphql/cache

cache

For more advanced use-cases caching may be wanted and can easily be added by including the package.

Installation

> npm install -s @tiny-graphql/core

Optionaly install the cache as well

> npm install -s @tiny-graphql/core @tiny-graphql/cache

Usage

import { createClient } from '@tiny-graphql/core';
import { createCache } from '@tiny-graphql/cache'; // Optional

const client = createClient({
  cache: createCache(), // Optional
  url: '<YOUR_URL>'
});

async function sayHello(name) {
  const result = await client.execute({
    query: `
      query SayHello($name: String) {
        hello(name: $name)
      }
    `,
    variables: {
      name: 'World'
    }
  });

  if (result.errors || !result.data) {
    throw new Error('Could not say hello');
  }

  return result.data.hello;
}

About

A tiny GraphQL suite for making your dev and user experience better than ever.


Languages

Language:TypeScript 100.0%