1.1.3 • Published 5 years ago

gery v1.1.3

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

Gery

npm Build Status Coverage Status npm GitHub license

A light weight GraphQL GraphQLClient

Installation

yarn add gery

Quick start

import { query } from 'graphql-request'
import { gql } from 'gql-tag' // editor helper

const GET_PERSONS = gql`
  {
    allPersons {
      id
      name
    }
  }
`

const endpoint = 'https://api.graph.cool/simple/v1/swapi'

query(endpoint, GET_PERSONS).then(data => console.log(data))

Use Client

import { GraphQLClient } from 'gery'
import { gql } from 'gql-tag' // editor helper

const GET_PERSONS = gql`
  {
    allPersons {
      id
      name
    }
  }
`
const GraphQLClient = new GraphQLClient({
  endpoint: 'https://api.graph.cool/simple/v1/swapi',
})

GraphQLClient.query(GET_PERSONS).then(data => console.log(data))

Variables

const GET_PERSON = gql`
  query getPerson($id: ID) {
    Person(id: $id) {
      id
      name
    }
  }
`

const data = await query(endpoint, GET_PERSON, {
  id: 'cj0nv9peiewhf013011i9a4h2',
})

Typescript

interface Person {
  Person: {
    id: string
    name: string
  }
}

const GET_PERSON = gql`
  query getPerson($id: ID) {
    Person(id: $id) {
      id
      name
    }
  }
`

const data = await query<Person>(endpoint, GET_PERSON, {
  id: 'cj0nv9peiewhf013011i9a4h2',
})

License

MIT License

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago