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

Commit

Permalink
chore(dependencies): update to rxjs >= 6
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The RxJS versions has a breaking change, so all clients
need to adopt RxJS version 6 or above
  • Loading branch information
Daniel Schmidt authored and GeorgiSTodorov committed Jan 7, 2019
1 parent 6c70818 commit 2bd9ff0
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 174 deletions.
12 changes: 12 additions & 0 deletions .vscode/bookmarks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"path": "$ROOTPATH$/src/index.ts",
"bookmarks": [
{
"line": 268,
"column": 67,
"label": ""
}
]
}
]
50 changes: 29 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ import graphql from "reactive-graphql";

import { makeExecutableSchema } from "graphql-tools";
import gql from "graphql-tag";
import { Observable } from "rxjs";
import { from, interval, of } from "rxjs";
import { map, merge, scan, combineLatest } from "rxjs/operators";
import { componentFromStream } from "@dcos/data-service";

// mocked API clients that return Observables
const oldPosts = Observable.from(["my first post", "a second post"]);
const newPosts = Observable.interval(3000).map(v => `Blog Post #${v + 1}`);
const oldPosts = from(["my first post", "a second post"]);
const newPosts = interval(3000).pipe(map(v => `Blog Post #${v + 1}`));
const fetchPosts = () =>
oldPosts.merge(newPosts).scan((acc, item) => [...acc, item], []);
oldPosts.pipe(
merge(newPosts),
scan((acc, item) => [...acc, item], [])
);
const votesStore = {};
const fetchVotesForPost = name => Observable.of(votesStore[name] || 0);
const fetchVotesForPost = name => of(votesStore[name] || 0);

const schema = makeExecutableSchema({
typeDefs: `
Expand All @@ -47,8 +51,10 @@ const schema = makeExecutableSchema({
resolvers: {
Query: {
posts(parent, args, context) {
return fetchPosts().map(emittedValue =>
emittedValue.map((value, index) => ({ id: index, title: value }))
return fetchPosts().pipe(
map(emittedValue =>
emittedValue.map((value, index) => ({ id: index, title: value }))
)
);
}
},
Expand All @@ -71,17 +77,19 @@ const query = gql`

const postStream = graphql(query, schema);
const PostsList = componentFromStream(propsStream =>
propsStream.combineLatest(postStream, (props, result) => {
const {
data: { posts }
} = result;

return posts.map(post => (
<div>
<h3>{post.title}</h3>
</div>
));
})
propsStream.pipe(
combineLatest(postStream, (props, result) => {
const {
data: { posts }
} = result;

return posts.map(post => (
<div>
<h3>{post.title}</h3>
</div>
));
})
)
);

function App() {
Expand All @@ -103,11 +111,11 @@ ReactDOM.render(<App />, rootElement);

## API

The first argument you pass into `reactive-graphql` is an executable schema, the second one a parsed GraphQL query. You can pass in the root context as an object as a third parameter.
The first argument you pass into `reactive-graphql` is an executable schema, the second one a parsed GraphQL query. You can pass in the root context as an object as a third parameter.

The implementation will always return an Observable.
The implementation will always return an Observable.
If any of the resolvers returns an error the implementation will emit the error on the stream.
Otherwise the data will be wrapped in a `{ data }` object, like most implementations handle this.
Otherwise the data will be wrapped in a `{ data }` object, like most implementations handle this.

## License

Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/*-test.js?(x)", "**/__tests__/**/*-test.ts?(x)"]
testMatch: ["**/__tests__/**/*-test.js?(x)", "**/__tests__/**/*-test.ts?(x)"],
testPathIgnorePatterns: ["/node_modules/", "<rootDir>/dist/"]
};
56 changes: 20 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"build": "tsc -p tsconfig.dist.json"
},
"dependencies": {
"graphql": "14.0.2"
"graphql": "^14.0.2"
},
"peerDependencies": {
"rxjs": "5.5.10"
"rxjs": "^6.0.0"
},
"devDependencies": {
"@types/graphql": "14.0.2",
Expand All @@ -28,8 +28,8 @@
"graphql-tools": "4.0.3",
"jest": "23.6.0",
"rimraf": "2.6.2",
"rxjs": "5.5.10",
"rxjs-marbles": "2.3.1",
"rxjs": "6.3.3",
"rxjs-marbles": "5.0.0",
"semantic-release": "15.12.4",
"ts-jest": "23.10.5",
"typescript": "3.2.1"
Expand Down
Loading

0 comments on commit 2bd9ff0

Please sign in to comment.