1.0.2 • Published 7 years ago

graphql-query-merge v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

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
  • 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
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago