Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangvvo committed May 23, 2021
1 parent 6c3cf51 commit 27c197c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 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,19 @@ 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 +120,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.

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

(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

0 comments on commit 27c197c

Please sign in to comment.