Closed acomito closed 6 years ago
Not sure! The graphQLServer
you're given is express()
:
https://github.com/apollographql/meteor-integration/blob/master/src/main-server.js#L59
@acomito Did you ever get engine working with this package? I haven't been able to it working using "apollo-engine": "^1.1.1"
@stolinski I haven't tried either option, but there's a docs section on Meteor:
https://www.apollographql.com/docs/engine/setup-node.html#not-express
in addition to the section on express
Hey @stolinski it's been a long time. I'm not sure I remember if I ever got the full schema read into engine. This is the final file I used:
import { createApolloServer } from 'meteor/apollo';
import { makeExecutableSchema } from 'graphql-tools';
import { typeDefs, resolvers } from '/imports/api/schema';
import { loadSchema, getSchema } from 'graphql-loader';
import { initAccounts } from 'meteor/nicolaslopezj:apollo-accounts';
import cors from 'cors';
import loaders from '/imports/api/loaders';
import compression from 'compression';
import { Engine } from 'apollo-engine';
import bodyParser from 'body-parser';
const engineApiKey = Meteor.settings.public.config.engineApiKey;
const engineConfig = {
apiKey: engineApiKey,
logging: {
level: 'DEBUG' // Engine Proxy logging level. DEBUG, INFO, WARN or ERROR
}
};
if (engineApiKey) {
engine = new Engine({ engineConfig });
engine.start();
}
//set options
// Load all accounts related resolvers and type definitions into graphql-loader
initAccounts({
loginWithPassword: true
});
// Load all your resolvers and type definitions into graphql-loader
loadSchema({ typeDefs, resolvers });
// Gets all the resolvers and types definitions loaded in graphql-loader
export const schema = makeExecutableSchema(getSchema());
//create server
createApolloServer(
{
schema,
context: { loaders },
debug: Meteor.isDevelopment,
},
{
configServer: graphQLServer => {
if (Meteor.isDevelopment) {
graphQLServer.use(cors())
}
graphQLServer.use(bodyParser.urlencoded({limit: '50mb', extended: false}));
graphQLServer.use(bodyParser.json({limit: '50mb'}));
if (engineApiKey) {
graphQLServer.use(engine.expressMiddleware());
}
// compression
graphQLServer.use(compression());
}
}
);
The two odd items are oaders are from facebook dataloader and initAccounts is from apollo-meteor-accounts
@lorensr I've read those over a few times, the docs mention using engine.listen() instead of app.listen() but seeing as how we aren't using app.listen() with this package, I have no idea how it fits in. You mentioned above that "The graphQLServer you're given is express()" leading me to try:
createApolloServer(
{
schema,
tracing: true,
cacheControl: true,
},
{
configServer: graphQLServer => {
engine.listen({
port: 3000,
expressApp: graphQLServer,
});
},
}
);
But that just gets me a white screen saying "Cannot GET /"
I haven't found an example anywhere of someone using the newer engine api with Meteor and am pretty stuck. If we figure it out, I can add a PR to the docs here showing it.
@acomito Unfortunately the API has changed and you no longer use Engine({ engineConfig }) or engine.start();
@lorensr I'm seeing
Meteor Just call meteorListen on the built-in WebApp server at the top level of your app’s server code:
engine.meteorListen(WebApp);
But I have no idea how that fits in the context of this package.
I see the full example is simply just
import { WebApp } from 'meteor/webapp';
const engine = new ApolloEngine({
apiKey: 'key'
});
engine.meteorListen(WebApp);
Sorry for filling your inbox. I wish MDG would provide full up to date examples. Small code snippets here and there make this stuff way more difficult than it needs to be. Maybe I'll get to work on a examples repo. Ugh.
I can't seem to get engine to see my schemas and I think it then can't do a trace. Does anything stand out that I'm missing? Or does createApolloServer not work exactly like vanilla graphl express?