Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement subscription #94

Closed
wants to merge 15 commits into from
23 changes: 17 additions & 6 deletions README.md
Expand Up @@ -29,8 +29,7 @@ Done in 141.94s.

### Support for GraphQL spec

The goal is to support the [June 2018 version of the GraphQL spec](https://facebook.github.io/graphql/June2018/). At this moment,
the only missing feature is support for Subscriptions.
The goal is to support the [June 2018 version of the GraphQL spec](https://facebook.github.io/graphql/June2018/).

#### Differences to `graphql-js`

Expand Down Expand Up @@ -91,10 +90,18 @@ if (!isCompiledQuery(compiledQuery)) {
#### Execute the Query

```js
const executionResult = await compiledQuery.query();
const executionResult = await compiledQuery.query(root, context, variables);
console.log(executionResult);
```

#### Subscribe to the Query

```js
const result = await compiledQuery.subscribe(root, context, variables);
for await (const value of result) {
console.log(value);
}
```
## API

### compiledQuery = compileQuery(schema, document, operationName, compilerOptions)
Expand All @@ -112,14 +119,18 @@ Compiles the `document` AST, using an optional operationName and compiler option
for overly expensive serializers
- `customJSONSerializer` {boolean, default: false} - Whether to produce also a JSON serializer function using `fast-json-stringify`. The default stringifier function is `JSON.stringify`

#### compiledQuery.compiled(root: any, context: any, variables: Maybe<{ [key: string]: any }>)
#### compiledQuery.query(root: any, context: any, variables: Maybe<{ [key: string]: any }>)

the compiled function that can be called with a root value, a context and the required variables to produce execution result.

#### compiledQuery.subscribe(root: any, context: any, variables: Maybe<{ [key: string]: any }>)

the compiled function that can be called with a root value, a context and the required variables.
(available for GraphQL Subscription only) the compiled function that can be called with a root value, a context and the required variables to produce either an AsyncIterator (if successful) or an ExecutionResult (error).

#### compiledQuery.stringify(value: any)

the compiled function for producing a JSON string. It will be `JSON.stringify` unless `compilerOptions.customJSONSerializer` is true.
The value argument should the return of the compiled GraphQL function.
The value argument should be the return of the compiled GraphQL function.

## LICENSE

Expand Down