GithubHelp home page GithubHelp logo

Comments (9)

HriBB avatar HriBB commented on April 18, 2024 3

This is my setup with 0.2.0-rc.1, hope it helps ...

import express from 'express'
import cors from 'cors'
import bodyParser from 'body-parser'
import async from 'asyncawait/async'
import await from 'asyncawait/await'
import { apolloExpress, graphiqlExpress } from 'apollo-server'
import { makeExecutableSchema } from 'graphql-tools'
import schema from './server/data/schema'
import resolvers from './server/data/resolvers'
import config from './config'

// create express server
const app = express()

// use cors
app.use(cors())

// use bodyparser
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())

...

// graphql endpoint
app.use('/graphql', apolloExpress(async (req) => {
  const user = await getAuthenticatedUser(req)
  return {
    schema: makeExecutableSchema({
      typeDefs: schema,
      resolvers,
      allowUndefinedInResolve: true,
    }),
    context: { user } // add user to the context
  }
}))

// graphiql endpoint
app.use('/graphiql', graphiqlExpress({
  endpointURL: '/graphql',
}))

// start express server
app.listen(config.server.port, () => console.log(
  `==> GraphQL Server is now running on http://localhost:${config.server.port}`
))

from apollo-server.

nnance avatar nnance commented on April 18, 2024 2

@savovs @HriBB Guys, @rszewczyk is correct. We made a mistake and released an RC version of the project to NPM. We have fixed the problem and now when you npm install apollo-server you will get version 0.1.5 which is the working version. Please make sure you use this version until we get the release candidate fully working and documented.

Sorry for any hassle this may have caused.

from apollo-server.

rszewczyk avatar rszewczyk commented on April 18, 2024

I ran into the same problem. It looks like there were breaking changes from v0.1.5 to the current version (0.2.0-rc.1) that aren't yet covered in the tech preview docs. If you install v0.1.5, you should have better luck.

Actually, I didn't feel satisfied with the above answer, so here's what I was able to get working with the current version:
https://gist.github.com/rszewczyk/9408f0aa70b33b20d5372f23474bee4e

from apollo-server.

helfer avatar helfer commented on April 18, 2024

I believe this is fixed now. Feel free to re-open if it's still not working for you.

from apollo-server.

scottmcpherson avatar scottmcpherson commented on April 18, 2024

@helfer @nnance I'm still getting this error with a fresh install of apollo in a Meteor integration:

W20160810-06:05:07.119(-4)? (STDERR) TypeError: apolloServer is not a function
W20160810-06:05:07.119(-4)? (STDERR)     at createApolloServer (packages/apollo/main-server.js:21:34)
W20160810-06:05:07.120(-4)? (STDERR)     at meteorInstall.server.server.js (server/server.js:5:1)
W20160810-06:05:07.121(-4)? (STDERR)     at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
W20160810-06:05:07.121(-4)? (STDERR)     at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
W20160810-06:05:07.121(-4)? (STDERR)     at /Users/scott/Develop/Meteor/AdAbounds/.meteor/local/build/programs/server/app/app.js:89:1
W20160810-06:05:07.122(-4)? (STDERR)     at /Users/scott/Develop/Meteor/AdAbounds/.meteor/local/build/programs/server/boot.js:297:10
W20160810-06:05:07.122(-4)? (STDERR)     at Array.forEach (native)
W20160810-06:05:07.122(-4)? (STDERR)     at Function._.each._.forEach (/Users/scott/.meteor/packages/meteor-tool/.1.4.0-1.nv68bz++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160810-06:05:07.123(-4)? (STDERR)     at /Users/scott/Develop/Meteor/AdAbounds/.meteor/local/build/programs/server/boot.js:133:5
W20160810-06:05:14.321(-4)? (STDERR) WARNING: npm peer requirements (for apollo) not installed:
W20160810-06:05:14.322(-4)? (STDERR)  - [email protected] installed, apollo-server@^0.1.1 needed

It looks like the latest [email protected] is incompatible with the apollo atmosphere package?

from apollo-server.

Grmiade avatar Grmiade commented on April 18, 2024

@scottmcpherson Look this: http://docs.apollostack.com/apollo-server/migration.html :)

from apollo-server.

scottmcpherson avatar scottmcpherson commented on April 18, 2024

Thanks @Grmiade :) I guess I'm not 100% sure how this ties in with the apollo atmosphere package and the createApolloServer function.

I'm guessing the apollo atmosphere package still uses the old apolloServer?

Right now, in my server.js I'm using the createApolloServer function:

import { createApolloServer } from 'meteor/apollo';
import { schema, resolvers } from '/imports/api/schema';

createApolloServer({
  graphiql: true,
  pretty: true,
  schema,
  resolvers,
});

Do you know if createApolloServer is no longer the recommended approach in a Meteor app?

from apollo-server.

scottmcpherson avatar scottmcpherson commented on April 18, 2024

I'm guessing the apollo atmosphere package still uses the old apolloServer?

Found the answer to the first question:
https://github.com/apollostack/meteor-integration/blob/master/main-server.js#L3

from apollo-server.

bwhitty avatar bwhitty commented on April 18, 2024

The answer to your question is on the last two lines:

W20160810-06:05:14.321(-4)? (STDERR) WARNING: npm peer requirements (for apollo) not installed:
W20160810-06:05:14.322(-4)? (STDERR)  - [email protected] installed, apollo-server@^0.1.1 needed

The meteor integration currently only supports apollo server 0.1.x, but you have the backwards incompatible 0.2.x installed. You need to make sure you have the correct version of Apollo server installed.

from apollo-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.