Fragment (companyQueries.js)
export const CompanyFragment = gql`
fragment company on WithApiKeys {
company {
id
apiKeys {
id
token
insertedAt
}
}
}
`
Beginning of usage (withCreateApiKeyMutation.js)
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
import CompanyFragment from '../../../utils/QueryFragments/companyQueries'
console.log(CompanyFragment)
const QUERY = gql`
query {
viewer {
id
...company
}
}
${CompanyFragment}
Error given by compiler
Error on line 3 of companyQueries.js
TypeError: Object(...) is not a function
export const CompanyFragment = gql <--line 3
If anyone could provide an insight on this it would be greatly appreciated!
I guess you did not import or imported the wrong gql
. In the last year the API was changed quite a bit.
You should not import it like
import { gql } from 'react-apollo';
but from this package
import gql from 'graphql-tag';