@coatl/gql
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@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' }
)

Package Sidebar

Install

npm i @coatl/gql

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

14.4 kB

Total Files

5

Last publish

Collaborators

  • carlos-burelo