Any way to use GraphQL the "non-Meteor" way?

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. :confused: 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.

somebody took stephen griders course…

I liked the GraphQLObjectType at first too because it was more simpleschema/mongoosey but you get used to the other shorthand pretty quick. It’s easier to read too. I would just struggle through the shorthand for a day and then it’ll be an afterthought. I’m about to look into using .graphql files which I think have syntax highlighting… its tough to read inside of a es6 template string.

1 Like

Yeah. Why on earth did he choose that style, when no one else uses it? I’ve lost a bit of faith in his courses now…

yeah I guess it was a bad call but it’s only 25% of understanding graphql. I was generally happy with the course.

It was definitely a good course. Though I was disappointed because I felt like I had to backtrack and relearn schemas and resolvers from scratch again… the right way.