Skip to content

AndersDJohnson/use-redux-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

46 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

use-redux-graphql

Connect to your Redux state with a GraphQL query client-side via a React Hook.

โš›๏ธ:sunglasses:โš›๏ธ

This can help as you migrate an existing application from storing API response data in Redux and accessing through selectors toward fetching it from a GraphQL server via React Hooks.

Queries will automatically re-execute whenever state changes to get the latest data.

If you don't use Apollo, see use-redux-graphql for full documentation.

Otherwise for Apollo, see use-redux-graphql-apollo.

Here's a preview:

import * as React from "react";
import gql from "graphql-tag";
import { useReduxGraphQuery } from "use-redux-graphql";

const COMP_QUERY = gql`
  {
    redux {
      name
      nested {
        flag
      }
    }
  }
`;

export const Comp = () => {
  const { data } = useReduxGraphQuery(COMP_QUERY);

  return <h1>name: {data?.redux?.name}</h1>;
};

About

โš›๏ธ๐Ÿ˜Žโš›๏ธ Connect to Redux state with GraphQL query client-side via React Hook.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published