An open API service indexing awesome lists of open source software.

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

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