question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apollo Engine Example

See original GitHub issue

I run into this issue regarding the Example with Apollo Engine - (Because I install the lastest version of Apollo Engine) "apollo-engine": "^1.1.0",

throw new Error(`As of apollo-engine 1.x, the Engine class has been replaced with a simpler API. See https://www.apollographql.com/docs/engine/1.0-migration.html to learn how to migrate.`);

So I tried and come up with this solution

require('dotenv').config()
const { GraphQLServer } = require('graphql-yoga')
const { ApolloEngine } = require('apollo-engine')
const compression = require('compression')

const typeDefs = `
  type Query {
    hello(name: String): String!
  }`

const resolvers = {
  Query: {
    hello: (_, { name }) => `Hello ${name || 'World'}`,
  },
}

const server = new GraphQLServer({ typeDefs, resolvers })


// Enable gzip compression
// ref: https://www.apollographql.com/docs/engine/setup-node.html#enabling-compression
server.express.use(compression())


const engine = new ApolloEngine({
  apiKey: process.env.APOLLO_ENGINE_API
});

// Instead of app.listen():
engine.listen({
  port: 4004,
  graphqlPaths: ['/'],
  expressApp: server.express,
  launcherOptions: {
    startupTimeout: 3000,
  },
}, () => {
  console.log('Apollo Engine Listening!');
});

server.start({
  tracing: true,
  cacheControl: true,
  port: parseInt(process.env.Port, 10) || 4000
}, () => console.log('GraphQL Server Server is running on localhost:4000'))

It is working now.

But I am not sure if this is an optimal solution. Can someon gives me a hint.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
efleurinecommented, Apr 27, 2018

@kachkaev it was not with the upgraded version. In fact I am seing it after you mention it. it seems I clone the repo just before the merge was made

0reactions
stale[bot]commented, Nov 30, 2018

Hey 👋, It seems like this issue has been inactive for some time. In need for maintaining clear overview of the issues concerning the latest version of graphql-yoga we’ll close it. Feel free to reopen it at any time if you believe we should futher discuss its content. 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apollo Graph Platform
A complete system to build, manage, and access a graph · A single map of all your data and services · Easy to...
Read more >
apollo-engine examples - CodeSandbox
Apollo Engine Examples. Learn how to use apollo-engine by viewing and forking example apps that make use of apollo-engine on CodeSandbox.
Read more >
Optimizing GraphQL with Apollo Engine [Tutorial] - Packt Hub
In this article, we will start off with setting up Apollo Engine. Further, we will learn how to analyze schemas, check how our...
Read more >
A complete introduction to Apollo, the GraphQL toolkit
Apollo is a suite of tools to create a GraphQL server, and to consume a GraphQL API. Let's explore Apollo in detail, both...
Read more >
GitHub - apollographql/apollo-tooling
Tooling for development and production Apollo workflows - GitHub ... Set "tsFileExtension" to specify a different file extension, for example "d.ts" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found