@coatl/gql
v0.0.1
Published
minimal graphql client written in typescript with zero dependencies
Downloads
2
Maintainers
Readme
@coatl/gql
A GraphQL client for Node.js (>=18) and the browser.
Features
- [x] Zero dependencies
- [x] Fully typed
- [x] Queries
- [x] Mutations
- [x] Subscriptions (pending)
- [x] File uploads (pending)
Installation
# using npm
npm install @coatl/gql
# using yarn
yarn add @coatl/gql
# using pnpm
pnpm add @coatl/gql
Usage
import GraphClient from '@coatl/gql';
const { query, mutate } = GraphClient('http://localhost:4000/graphql')
type UsersQuery = {
id: number
name: string
}
const { users } = await query<UsersQuery[], 'users'>(
`users {
id
name
}`
)
const { createUser } = await mutate<UsersQuery, 'createUser'>(
`createUser(name: $name){
id
name
}`
{ name: 'John Doe' }
)