Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beeman/kikstart-graphql-client
🚀 Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.
https://github.com/beeman/kikstart-graphql-client
apollo-client apollo-link apollo-link-http graphql graphql-client graphql-subscriptions nodejs subscriptions subscriptions-transport-ws typescript
Last synced: 3 months ago
JSON representation
🚀 Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.
- Host: GitHub
- URL: https://github.com/beeman/kikstart-graphql-client
- Owner: beeman
- License: mit
- Created: 2019-11-22T23:16:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-16T01:36:24.000Z (over 3 years ago)
- Last Synced: 2024-09-28T21:22:56.246Z (4 months ago)
- Topics: apollo-client, apollo-link, apollo-link-http, graphql, graphql-client, graphql-subscriptions, nodejs, subscriptions, subscriptions-transport-ws, typescript
- Language: TypeScript
- Homepage:
- Size: 1.36 MB
- Stars: 36
- Watchers: 3
- Forks: 5
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kikstart-graphql-client
Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/beeman/kikstart-graphql-client.svg)
![GitHub repo size](https://img.shields.io/github/repo-size/beeman/kikstart-graphql-client.svg)
![npm](https://img.shields.io/npm/dw/kikstart-graphql-client.svg)
![npm](https://img.shields.io/npm/dm/kikstart-graphql-client.svg)
![npm](https://img.shields.io/npm/dy/kikstart-graphql-client.svg)
![npm](https://img.shields.io/npm/dt/kikstart-graphql-client.svg)
![NPM](https://img.shields.io/npm/l/kikstart-graphql-client.svg)
![npm](https://img.shields.io/npm/v/kikstart-graphql-client.svg)
![GitHub last commit](https://img.shields.io/github/last-commit/beeman/kikstart-graphql-client.svg)
![npm collaborators](https://img.shields.io/npm/collaborators/kikstart-graphql-client.svg)## Usage
Install dependency:
```shell script
yarn add kikstart-graphql-client graphql
```Import `GraphQLClient`:
```typescript
import { GraphQLClient } from 'kikstart-graphql-client';
```Create instance:
```typescript
const client = new GraphQLClient({
uri: 'http://localhost:4000/graphql',
wsUri: 'ws://localhost:4000/graphql',
})
```Run Query:
```typescript
async getStatus() {
const { data, error } = await this.client.runQuery(`
query { status }
`);
if (error) {
throw error
}
return data.status
}
```Run Subscription:
```typescript
client.runSubscription(query)
.subscribe({
next: res => console.log(JSON.stringify(res.data.statusSubscription, null, 2)),
error: error => console.error(error),
complete: () => console.log('done'),
})
}
```## Credits
- Uses code from [graphcurl](https://github.com/graphql-in-depth/graphcurl).
- Based on [npm-typescript-package-boilerplate](https://github.com/93v/npm-typescript-package-boilerplate)## MIT License