Skip to content

Commit bce0b6e

Browse files
authored
fix: tests (#37)
* chore: test against node v14 * fix: tests * chore: update readme for new apollo-server-express
1 parent 5802702 commit bce0b6e

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ language: node_js
22
node_js:
33
- 10
44
- 12
5-
after_success:
6-
- npm run coverage
5+
- 13
6+
- 14
7+
cache: npm
8+
branches:
9+
only:
10+
- master

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ npm install graphql-constraint-directive
1515
```js
1616
const { constraintDirective, constraintDirectiveTypeDefs } = require('graphql-constraint-directive')
1717
const express = require('express')
18-
const bodyParser = require('body-parser')
19-
const { graphqlExpress } = require('apollo-server-express')
18+
const { ApolloServer } = require('apollo-server-express')
2019
const { makeExecutableSchema } = require('graphql-tools')
2120
const typeDefs = `
2221
type Query {
@@ -36,8 +35,9 @@ const schema = makeExecutableSchema({
3635
schemaTransforms: [constraintDirective()]
3736
})
3837
const app = express()
38+
const server = new ApolloServer({ schema })
3939

40-
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }))
40+
server.applyMiddleware({ app })
4141

4242
```
4343

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
],
3030
"devDependencies": {
3131
"apollo-server-express": "^2.14.2",
32-
"body-parser": "^1.18.3",
3332
"coveralls": "^3.1.0",
3433
"express": "^4.16.3",
3534
"graphql": "^15.0.0",

test/setup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const express = require('express')
2-
const bodyParser = require('body-parser')
3-
const { graphqlExpress } = require('apollo-server-express')
2+
const { ApolloServer } = require('apollo-server-express')
43
const { makeExecutableSchema } = require('@graphql-tools/schema')
54
const request = require('supertest')
65
const { constraintDirective, constraintDirectiveTypeDefs } = require('../')
@@ -12,8 +11,9 @@ module.exports = function (typeDefs, formatError, resolvers) {
1211
resolvers
1312
})
1413
const app = express()
14+
const server = new ApolloServer({ schema, formatError })
1515

16-
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema, formatError }))
16+
server.applyMiddleware({ app })
1717

1818
return request(app)
1919
}

0 commit comments

Comments
 (0)