type Thread {
_id: ID!
}
input ThreadParams {
_id: ID
type: String
}
type Query {
threads(params: ThreadParams): [Thread],
}
type Mutation {
createThread(params: ThreadParams): Thread
}
Typically I just throw it in one big string like
export const ThreadSchema = [`
type Thread {
_id: ID!
}
input ThreadParams {
_id: ID
type: String
}
type Query {
threads(params: ThreadParams): [Thread],
}
type Mutation {
createThread(params: ThreadParams): Thread
}
`]
export const typeDefs = [
...ThreadSchema
];
export const resolvers = merge( ThreadResolvers ); //ThreadResolvers not shown here
then in another file:
// Load all your resolvers and type definitions into graphql-loader
loadSchema({ typeDefs, resolvers });
// Gets all the resolvers and type definitions loaded in graphql-loader
export const schema = makeExecutableSchema(getSchema());
how does this work with graphql files (in meteor)?
I have it working that way (holding the graphql stuff inside a es6 strings in an array). My question is how would I do that same exact thing, using a .graphql file.
If you’re looking at writing queries/types in .graphql or .gql files and use imports to load fragments, see this Medium post “Webpack’ing your GraphQL Documents”