1.0.2 • Published 7 years ago
graphql-query-merge v1.0.2
graphql-query-merge
Utility to merge multiples queries
How to use?:
Example with react-apollo
:
import User from '../Queries/User.gql'
import Profile from '../Queries/Profile.gql'
import { Query } from 'react-apollo'
import { merge } from 'graphql-query-merge'
const Component = ({ profile_id }) => <Query query={merge(User, Profile)}>
{res => <Profile user={res.data.user} profile={res.data.profile} />}
</Query>
API:
merge(...queries)
- Parameters:
- queries:
Array<DocumentNode>
: Array of Queries to Merge
- queries:
- Returns
DocumentNode
: Resultant Query
Internal Notes:
merge()
will do the following:- Merge query Bodies (aka
SelectionSet
's) - Merge query Parameters (aka
variableDefinitions
) - Merge query Directives (aka
directives
) - Remove query name
- Merge query Bodies (aka