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: 9 days 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 (5 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.









## 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