I have a queries file that looks like this:
import {gql} from \'react-apollo\';
const queries = {
getApps: gql`
{
apps {
id
name
I'm using react-adopt to make this. It's really simple and keep our code clean.
Simple example:
import { adopt } from 'react-adopt';
...
render() {
const Composed = adopt({
first: ({ render }) => { render } ,
second: ({ render }) => { render }
});
return (
({ first, second }) => {
console.log('first', first)
console.log('second', second)
// validations (loading, error)
return (
Your JSX
)
}
)
}
...
There are a lot of examples using
const Composed = adopt({
first: ,
second:
});
Be careful with
component, It needs a children, otherwise, it will have the following error:
Warning: Failed prop type: The prop children is marked as required in Query, but its value is undefined.
To avoid the previous warning, I have found a possible solution:
first: ({ render }) => { render }
Hope it helps you!