0.0.2 • Published 5 years ago

@tiny-graphql/core v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Tiny GraphQL Core core

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

Usage

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

const client = createClient({
  url: '<YOUR_URL>'
});

async function sayHello(name: string): string {
  const result = await client.execute<{ hello?: string }>({
    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;
}