Minimal graphql client
Inspired by graphql-request by Prisma.
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,
})
You can add types to your query response.
interface Person {
name: string
}
const query = await client.query<Person>({
query,
})