An open API service indexing awesome lists of open source software.

https://github.com/unlikelystudio/simpleql

📚 Simple graphql client
https://github.com/unlikelystudio/simpleql

fetch graphql graphql-client typescript

Last synced: 5 months ago
JSON representation

📚 Simple graphql client

Awesome Lists containing this project

README

          


SimpleQL



npm version


Minimal graphql client


_Inspired by [graphql-request](https://github.com/prisma-labs/graphql-request) by Prisma._

## Getting started

```bash

npm i @unlikelystudio/simpleql

```

```typescript
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.

```typescript
interface Person {
name: string
}

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