create-graphql-server icon indicating copy to clipboard operation
create-graphql-server copied to clipboard

Update apollo version

Open lorensr opened this issue 8 years ago • 3 comments

From "graphql-server-express": "^0.4.3" to apollo-server-express, currently at 1.2.0

lorensr avatar Oct 30 '17 05:10 lorensr

Here is my diff from upgrading:

diff --git a/.babelrc b/.babelrc
index 9e3d274..f2e3127 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,6 +1,3 @@
 {
-  "presets": [
-    "es2015",
-    "stage-2"
-  ]
+  "presets": ["env", "stage-2"]
 }
diff --git a/package.json b/package.json
index e03aeb8..f68108f 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
     "babel-cli": "6.16.0",
     "babel-core": "6.17.0",
     "babel-eslint": "7.0.0",
-    "babel-preset-es2015": "6.16.0",
+    "babel-preset-env": "^1.6.1",
     "babel-preset-react": "6.16.0",
     "babel-preset-stage-2": "6.17.0",
     "babel-register": "6.16.3",
@@ -30,6 +30,7 @@
     "nodemon": "1.11.0"
   },
   "dependencies": {
+    "apollo-server-express": "^1.2.0",
+    "graphql": "^0.11.7",
+    "graphql-tools": "^2.6.1",
-    "graphql": "0.7.2",
-    "graphql-server": "^0.3.2",
-    "graphql-server-express": "^0.4.3",
-    "graphql-tools": "^0.8.2",
     "bcrypt": "^1.0.2",
     "body-parser": "1.15.2",
diff --git a/server/index.js b/server/index.js
index a722448..5b3c63b 100644
--- a/server/index.js
+++ b/server/index.js
@@ -1,5 +1,5 @@
 import express from 'express'
-import { graphqlExpress, graphiqlExpress } from 'graphql-server-express'
+import { graphqlExpress, graphiqlExpress } from 'apollo-server-express'
 import { createServer } from 'http'
 import { SubscriptionServer } from 'subscriptions-transport-ws'
 import bodyParser from 'body-parser'

It's working, but prints this error:

Name "__placeholder" must not begin with "__", which is reserved by GraphQL introspection. In a future release of graphql this will become a hard error.

And I get an error when I remove the __placeholder fields. Could do a single underscore, but then it shows up first in GraphiQL suggested field list

image

lorensr avatar Oct 30 '17 07:10 lorensr

Yeah the thing is we need to have some field in the initial schema we create. Although perhaps this restriction has been lifted?

tmeasday avatar Oct 30 '17 10:10 tmeasday

Still the case:

Error: Mutation fields must be an object with field names as keys or a function which returns such an object.

Guess you could, when the first type is added, eg remove type Mutation from index.js, and change eg Type.graphql from extends type Mutation to type Mutation

lorensr avatar Oct 30 '17 22:10 lorensr