Skip to content

unlikelystudio/simpleql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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,
})