Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using GraphQl inside the FilterPage Component #9

Open
fadeomar opened this issue Nov 26, 2019 · 0 comments
Open

Using GraphQl inside the FilterPage Component #9

fadeomar opened this issue Nov 26, 2019 · 0 comments
Labels

Comments

@fadeomar
Copy link
Collaborator

we will use the query many times in this component so first we need to import things that we need :

1- import the lodash.flowright to compose all queries to the component
import compose from 'lodash.flowright';

2- import all queries that we need from the query file
import {InitaialFilterQuery, FilterResultQuery } from '../queries';

replace the axios thing in the componentDidMount() with queryInitialFilter

  • using destruction to get the passed props to the queries
    • const {Loaction, Price, isRemote, type} = data ;
  • after this we should declared the variables in the query bind
  • we use two queries ,because of that we should use compose to bind two queries to the component like so :
export default compose(graphql(FilterResultQuery, {
    options: props => {
        return {
            variables: {
                location : props.loaction,
                isRemote : props.isRemote,
                price : props.price,
                type : props.type,
            }
        }
    },
name:"FilterResultQuery"
}),
graphql(InitaialFilterQuery, {name: InitaialFilterQuery}))(BookDetails);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant