These are a series of commits to allow cloud/sdr to work with Apollo Server 2.0.
Before, running npm install and npm start in the cloud/sdr/ui/sdr-app, as suggested by the ReadMe, would error out because the graphql functions were deprecated when we upgraded Apollo Server. Now, the errors no longer appear, but localhost:6001 is still not starting for different reasons unrelated to Apollo Server.
The commits are broken down by the errors I encountered and the fixes I applied to make them work, so hopefully they're easier to review. For more context, I've listed the error stacktraces below and the approach I took to resolve them by commit.
Migrate graphqlExpress usage over to Apollo Server 2.0 syntax
/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/app.js:62
appSvr.use('/graphql', bodyParser.json(), apolloUploadExpress(), graphqlExpress({ schema }))
^
TypeError: graphqlExpress is not a function
at Object.<anonymous> (/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/app.js:62:66)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
[nodemon] app crashed - waiting for file changes before starting...
We need to migrate over to the new pattern for using Apollo Server 2.0.
Change 'appSvr' to 'app' to resolve internal apollo error
/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/node_modules/apollo-server-express/dist/ApolloServer.js:78
app.use(this.getMiddleware(rest));
^
TypeError: Cannot read property 'use' of undefined
at ApolloServer.applyMiddleware (/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/node_modules/apollo-server-express/dist/ApolloServer.js:78:13)
at Object.<anonymous> (/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/app.js:80:8)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
[nodemon] app crashed - waiting for file changes before starting...
I think this means apollo-server internally expects that the app server is called app. Changing appSvr to app fixed this issue.
Migrate graphiqlExpress usage over to Apollo Server 2.0 syntax
/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/app.js:75
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql', })) // only needed for developers to interactively browse the db
^
TypeError: graphiqlExpress is not a function
at Object.<anonymous> (/Users/clement.ng/examples/cloud/sdr/ui/sdr-app/app.js:75:22)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
[nodemon] app crashed - waiting for file changes before starting...
These are a series of commits to allow
cloud/sdr
to work with Apollo Server 2.0.Before, running
npm install
andnpm start
in thecloud/sdr/ui/sdr-app
, as suggested by the ReadMe, would error out because thegraphql
functions were deprecated when we upgraded Apollo Server. Now, the errors no longer appear, butlocalhost:6001
is still not starting for different reasons unrelated to Apollo Server.The commits are broken down by the errors I encountered and the fixes I applied to make them work, so hopefully they're easier to review. For more context, I've listed the error stacktraces below and the approach I took to resolve them by commit.
Migrate graphqlExpress usage over to Apollo Server 2.0 syntax
We need to migrate over to the new pattern for using Apollo Server 2.0.
Change 'appSvr' to 'app' to resolve internal apollo error
I think this means
apollo-server
internally expects that the app server is calledapp
. ChangingappSvr
toapp
fixed this issue.Migrate graphiqlExpress usage over to Apollo Server 2.0 syntax
We need to migrate over to using GraphQL Playground.
Tested on
MacOS Catalina, npm -v 6.14.11, node -v v12.14.0
.