@unlikelystudio/simpleql

Minimal graphql client


Keywords
graphql, fetch, graphql-client, typescript
Install
npm install @unlikelystudio/simpleql@1.0.0

Documentation

SimpleQL

npm version

Minimal graphql client

Inspired by graphql-request by Prisma.

Getting started

npm i @unlikelystudio/simpleql
import SimpleQL from '@unlikelystudio/simpleql'
import gql from 'graphql-tag'

const client = new SimpleQL('https://api.unlikely.studio')

const query = `
  query Projects {
    projects(first: 3) {
      edges {
        node {
          title
          description
          image {
            src
            width
            height
          }
        }
      }
    }
  }
`

// OR

const query = gql`
  query Projects {
    projects(first: 3) {
      edges {
        node {
          title
          description
          image {
            src
            width
            height
          }
        }
      }
    }
  }
`

const query = await client.query({
  query,
})

Typescript users

You can add types to your query response.

interface Person {
  name: string
}

const query = await client.query<Person>({
  query,
})