I want to use some fragment:
import {gql} from "apollo-boost";
import "../fragments/cardFragments.graphql"
export const ADD_CARD = gql`
mutation AddCard {
createCard(input: {
private: true,
section: "school",
createdBy: "api/users/1"
}) {
card {
...CardFields
}
}
}
`;
export default {ADD_CARD}
cardFragments.graphql:
fragment CardFields on card {
id
private
section
createdBy {
id
}
}
Inside the console I get the error :
[GraphQL error]: Message: Unknown fragment "CardFields"., Location: [object Object], Path: undefined
Did I forgot something?
EDIT:
For the graphql fragmets to work I need to load it with webpack: Apollo docs
I did this with Webpack Encore
:
.addLoader({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
});
module.exports = Encore.getWebpackConfig();
Before I did this - I got an error for the not loadable .graphql extention inside of Webpack Encore
.
Is there something I do not see about creating cutsom loader with Webpack Encore
?
import "../fragments/cardFragments.graphql"
to do. A graphql file is not even valid JS code, so you must be relying on some build tool as well? – Dewsapollo-client
tag? – Dews