https://github.com/danielmschmidt/reactive-graphql-react
React bindings for reactive-graphql
https://github.com/danielmschmidt/reactive-graphql-react
react reactive reactive-graphql rxjs6
Last synced: 10 months ago
JSON representation
React bindings for reactive-graphql
- Host: GitHub
- URL: https://github.com/danielmschmidt/reactive-graphql-react
- Owner: DanielMSchmidt
- Created: 2019-01-18T09:43:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T05:03:14.000Z (over 1 year ago)
- Last Synced: 2024-10-30T08:30:11.686Z (over 1 year ago)
- Topics: react, reactive, reactive-graphql, rxjs6
- Language: TypeScript
- Size: 1.87 MB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reactive GraphQL React
React Hook bindings for [reactive-graphql](https://github.com/mesosphere/reactive-graphql).
## Usage
```ts
import gql from "graphql-tag";
import getReactiveGraphqlReact from "reactive-graphql-react";
const schema = getSchema(); // get a GraphQL schema
const useGraphql = getReactiveGraphqlReact(schema); // get the hook
export default function MyComponent() {
// Always up-to-date data
const [result, error] = useGraphql(gql`
query {
posts {
title
author {
name
}
}
}
`);
if (error) {
return
There has been an error fetching the data
;
}
if (!result) {
return
Loading, please wait
;
}
const {
data: { posts }
} = result;
return ;
}
```
## Setup
You need React in `>= 16.8.0-alpha.1`. Besides just run `npm install --save reactive-graphql-react` and you are ready to go.
## License
MIT