Skip to content

glennreyes/graphql-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

graphql-components

Install

yarn add graphql-components

Usage

import { gql } from 'graphql-components';

const GetDogsQuery = gql`
  query GetDogs {
    dogs {
      id
      name
    }
  }
`;

const GoodDogsBrent = () => (
  <GetDogsQuery>
    {({ loading, error, data }) => {
      if (error) return <Error />
      if (loading || !data) return <Fetching />

      return <DogList dogs={data.dogs} />
    }}
  </GetDogsQuery>
)

Or use .graphql files directly by adding following loader to your webpack config;

{
  test: /\.graphql/,
  use: 'graphql-components/loader',
},
import GetDogsQuery from './getDogsQuery.graphql';

const GoodDogsBrent = () => (
  <GetDogsQuery>
    {({ loading, error, data }) => {
      if (error) return <Error />
      if (loading || !data) return <Fetching />

      return <DogList dogs={data.dogs} />
    }}
  </GetDogsQuery>
)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published