Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit ccfa24b

Browse files
alexstratDaniel Schmidt
authored and
Daniel Schmidt
committed
feat: complete implementation (fragments, introspection...)
BREAKING CHANGE: - Removed support for Observable rootValue - Removed the support for Observable variables: If necessary, it can be done by the user with a simple: ```js variables$.pipe( switchMap(variables => graphql({ schema, source: query, variables })) ) ``` - Removed support for query as Document in graphql(): ```js // previously ok: graphql(schema, gql`query {}`) // now use: execute(schema, gql`query {}`) // or graphql(schema, `query {}`) ``` - Error handling: every expected errors (validation, syntax error, throwing resolver...) are pushed in the error field of the ExecutionResult, the RxJS stream does not throw in these cases anymore
1 parent 0f3f455 commit ccfa24b

19 files changed

+1574
-573
lines changed

README.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
Execute GraphQL queries against reactive resolvers (resolvers that return Observable) to get a reactive results.
88

9-
_This project aims to become a complete GraphQL implementation based around [RxJS](https://github.com/ReactiveX/rxjs)._
10-
119
## Install
1210

1311
```
@@ -19,13 +17,12 @@ $ npm i reactive-graphql --save
1917
The usage is very similar to `graphql-js`'s [`graphql`](https://graphql.org/graphql-js/graphql/#graphql) function, except that:
2018

2119
- resolvers can return an Observable
22-
- the returned value is an Observable
20+
- the result of a query is an Observable
2321

2422
```js
23+
import { graphql } from "reactive-graphql";
2524
import { makeExecutableSchema } from "graphql-tools";
26-
import gql from "graphql-tag";
2725
import { timer } from "rxjs";
28-
import graphql from "reactive-graphql";
2926

3027
const typeDefs = `
3128
type Query {
@@ -48,13 +45,13 @@ const schema = makeExecutableSchema({
4845
resolvers
4946
});
5047

51-
const query = gql`
48+
const query = `
5249
query {
5350
time
5451
}
5552
`;
5653

57-
const stream = graphql(query, schema);
54+
const stream = graphql(schema, query);
5855
// stream is an Observable
5956
stream.subscribe(res => console.log(res));
6057
```
@@ -70,20 +67,8 @@ outputs
7067
...
7168
```
7269

73-
## API
74-
75-
The first argument you pass into `reactive-graphql` is a GraphQL query, either parsed or as string, the second one is an executable schema. You can pass in the root context as an object as a third parameter. The variables can be passed as 4th parameter.
76-
77-
The implementation will always return an Observable.
78-
If any of the resolvers returns an error the implementation will emit the error on the stream.
79-
Otherwise the data will be wrapped in a `{ data }` object, like most implementations handle this.
80-
8170
## Caveats
82-
83-
Unsupported GraphQL features:
84-
85-
- fragments of all kinds
86-
- subscriptions (as everything is treated as a subscription)
71+
GraphQL Subscriptions are not supported (see [issue #27](https://github.com/mesosphere/reactive-graphql/issues/27)) as everything is treated as subscriptions.
8772

8873
## See Also
8974

0 commit comments

Comments
 (0)