I just did a crash course on GraphQL & Apollo, and I was disappointed to find that Meteor has its own way of doing things on the server end, none of which really matches what I just learned. Is there some way I can fire up my own GraphQL endpoint within Meteor?
(pardon anything that doesn’t make sense, I’m pretty new to GraphQL)
For example, Meteor/Apollo Server setup:
import { createApolloServer } from 'meteor/apollo';
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
import { typeDefs } from '/imports/api/schema';
import { resolvers } from '/imports/api/resolvers';
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
createApolloServer({
schema,
});
I’d rather not. I’d rather do it this way (set up types using GraphQLObjectType
, then pull into the RootQuery
:
const RootQuery = new GraphQLObjectType({
name: 'RootQueryType',
fields: () => ({
songs: {
type: new GraphQLList(SongType),
resolve() {
return Song.find({});
}
},
song: {
type: SongType,
args: { id: { type: new GraphQLNonNull(GraphQLID) } },
resolve(parentValue, { id }) {
return Song.findById(id);
}
},
lyric: {
type: LyricType,
args: { id: { type: new GraphQLNonNull(GraphQLID) } },
resolve(parentValue, { id }) {
return Lyric.findById(id);
}
}
})
});
I’d be grateful for any hack to use a regular express/GraphQL server as opposed to Apollo Server. Thanks!
Edit: I realize now that it’s a matter of Express GraphQL vs Apollo Server. And actually the way the GraphQL course did things is apparently not typical.