Skip to content

Commit 4134b3e

Browse files
committed
feat: upgrade to graphql@14
1 parent 6865e4a commit 4134b3e

File tree

8 files changed

+65
-53
lines changed

8 files changed

+65
-53
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/node-fetch": "1.6.7",
4343
"ava": "0.25.0",
4444
"cpx": "1.5.0",
45-
"graphql": "0.13.2",
45+
"graphql": "14.0.2",
4646
"rimraf": "2.6.2",
4747
"tslint": "5.9.1",
4848
"tslint-config-standard": "7.0.0",

src/__tests__/basic/findGraphQLConfigFile.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@ import test from 'ava'
22
import { dirname, join } from 'path'
33
import { mkdtempSync } from 'fs'
44
import { tmpdir } from 'os'
5-
const schema = require('../schema.json')
65
import { findGraphQLConfigFile, ConfigNotFoundError } from '../../'
76

8-
test('returns a correct config filename', (t) => {
7+
test('returns a correct config filename', t => {
98
const configFile = findGraphQLConfigFile(__dirname)
109
t.deepEqual(configFile, join(__dirname, '.graphqlconfig'))
11-
});
10+
})
1211

13-
test('returns a correct config filename for 1st level of sub directories', (t) => {
14-
const configFile = findGraphQLConfigFile(`${__dirname}/../sub-directory-config`)
15-
t.deepEqual(configFile, join(`${__dirname}/../sub-directory-config/sub-directory-2`, '.graphqlconfig'))
16-
});
12+
test('returns a correct config filename for 1st level of sub directories', t => {
13+
const configFile = findGraphQLConfigFile(
14+
`${__dirname}/../sub-directory-config`,
15+
)
16+
t.deepEqual(
17+
configFile,
18+
join(
19+
`${__dirname}/../sub-directory-config/sub-directory-2`,
20+
'.graphqlconfig',
21+
),
22+
)
23+
})
1724

18-
test('throws GraphQLConfigNotFoundError when config is not found', (t) => {
25+
test('throws GraphQLConfigNotFoundError when config is not found', t => {
1926
const tempDir = mkdtempSync(join(tmpdir(), 'graphql-config'))
2027
t.throws(() => findGraphQLConfigFile(tempDir), ConfigNotFoundError)
2128
})

src/__tests__/basic/getGraphQLConfig.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import test from 'ava'
22
import { join, resolve } from 'path'
33
import { printSchema } from 'graphql'
4-
const schema = require('../schema.json')
54
import { getGraphQLConfig, GraphQLConfig } from '../../'
65

76
const CONFIG_DIR = join(__dirname, 'config')
@@ -18,7 +17,9 @@ test('returns a correct name', t => {
1817
})
1918

2019
test('returns config for file', t => {
21-
const testWithSchemaConfig = config.getConfigForFile(resolve('./config/schema-a.graphql'))
20+
const testWithSchemaConfig = config.getConfigForFile(
21+
resolve('./config/schema-a.graphql'),
22+
)
2223
if (testWithSchemaConfig) {
2324
t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema')
2425
} else {
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import test from 'ava'
2-
const schema = require('../schema.json')
32
import { getGraphQLProjectConfig } from '../../'
43

5-
test('resolves schema from file', async (t) => {
4+
test('resolves schema from file', async t => {
65
const config = getGraphQLProjectConfig(__dirname)
76
const resolvedSchema = await config.resolveIntrospection()
87

9-
t.deepEqual(resolvedSchema, schema)
8+
t.snapshot(resolvedSchema)
109
})

src/__tests__/endpoint-extension/resolve.ts

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import test from 'ava'
22
import { graphql, introspectionQuery } from 'graphql'
3-
import { GraphQLProjectConfig, GraphQLEndpointsExtension } from '../../'
3+
import { GraphQLProjectConfig } from '../../'
44
import { serveSchema } from '../utils'
5-
const introspection = require('../schema.json')
65

7-
test.before(async (t) => {
6+
test.before(async t => {
87
return await serveSchema()
98
})
109

11-
1210
const confPath = `${__dirname}/.graphqlconfig`
1311

14-
test('getEndpointsMap when endpoint is string url', async (t) => {
12+
test('getEndpointsMap when endpoint is string url', async t => {
1513
const configData = {
1614
schemaPath: '../schema.json',
1715
extensions: {
@@ -23,10 +21,12 @@ test('getEndpointsMap when endpoint is string url', async (t) => {
2321

2422
const config = new GraphQLProjectConfig(configData, confPath)
2523
const endpoints = config.endpointsExtension
26-
t.deepEqual(endpoints && endpoints.getRawEndpointsMap(), { dev: { url: 'http://default' }})
24+
t.deepEqual(endpoints && endpoints.getRawEndpointsMap(), {
25+
dev: { url: 'http://default' },
26+
})
2727
})
2828

29-
test('getEndpointsMap when endpoint is single endpoint config', async (t) => {
29+
test('getEndpointsMap when endpoint is single endpoint config', async t => {
3030
const configData = {
3131
schemaPath: '../schema.json',
3232
extensions: {
@@ -43,10 +43,12 @@ test('getEndpointsMap when endpoint is single endpoint config', async (t) => {
4343

4444
const config = new GraphQLProjectConfig(configData, confPath, undefined)
4545
const endpoint = config.endpointsExtension
46-
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { dev: configData.extensions.endpoints.dev })
46+
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), {
47+
dev: configData.extensions.endpoints.dev,
48+
})
4749
})
4850

49-
test('getEndpointsMap when endpoint is endpoints map', async (t) => {
51+
test('getEndpointsMap when endpoint is endpoints map', async t => {
5052
const configData = {
5153
schemaPath: '../schema.json',
5254
extensions: {
@@ -65,22 +67,20 @@ test('getEndpointsMap when endpoint is endpoints map', async (t) => {
6567
const config = new GraphQLProjectConfig(configData, confPath, undefined)
6668

6769
const endpoint = config.endpointsExtension
68-
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(),
69-
{
70-
dev: {
71-
url: 'http://dev',
70+
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), {
71+
dev: {
72+
url: 'http://dev',
73+
},
74+
prod: {
75+
url: 'http://prod',
76+
subscription: {
77+
url: 'ws://prod',
7278
},
73-
prod: {
74-
url: 'http://prod',
75-
subscription: {
76-
url: 'ws://prod',
77-
},
78-
}
79-
}
80-
)
79+
},
80+
})
8181
})
8282

83-
test('resolveSchemaFromEndpoint should throw if non-existing endpoint is specified', async (t) => {
83+
test('resolveSchemaFromEndpoint should throw if non-existing endpoint is specified', async t => {
8484
const configData = {
8585
schemaPath: '../schema.json',
8686
extensions: {
@@ -97,25 +97,32 @@ test('resolveSchemaFromEndpoint should throw if non-existing endpoint is specifi
9797
const config = new GraphQLProjectConfig(configData, confPath, undefined)
9898
let error
9999
const endpoint = config.endpointsExtension
100-
error = t.throws(() => endpoint && endpoint.getEndpoint('prod').resolveSchema())
101-
t.regex(error.message, /"prod" is not valid endpoint name. Valid endpoint names: dev/)
100+
error = t.throws(
101+
() => endpoint && endpoint.getEndpoint('prod').resolveSchema(),
102+
)
103+
t.regex(
104+
error.message,
105+
/"prod" is not valid endpoint name. Valid endpoint names: dev/,
106+
)
102107
})
103108

104-
test('resolveSchemaFromEndpoint HTTP', async (t) => {
109+
test('resolveSchemaFromEndpoint HTTP', async t => {
105110
const configData = {
106111
schemaPath: '../schema.json',
107112
extensions: {
108113
endpoints: {
109-
dev: 'http://127.0.0.1:33333'
110-
}
114+
dev: 'http://127.0.0.1:33333',
115+
},
111116
},
112117
}
113118

114119
const config = new GraphQLProjectConfig(configData, confPath, undefined)
115-
if (!config.endpointsExtension){
120+
if (!config.endpointsExtension) {
116121
throw 'endpointExtension can\'t be empty'
117122
}
118-
const schema = await config.endpointsExtension.getEndpoint('dev').resolveSchema()
123+
const schema = await config.endpointsExtension
124+
.getEndpoint('dev')
125+
.resolveSchema()
119126
const resolvedIntrospection = await graphql(schema, introspectionQuery)
120-
t.deepEqual(resolvedIntrospection, introspection)
127+
t.snapshot(resolvedIntrospection)
121128
})

src/__tests__/introspection-query/getSchema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import test from 'ava'
22
import { join } from 'path'
33
import { printSchema } from 'graphql'
4-
const schema = require('../schema.json')
54
import { getGraphQLConfig, GraphQLConfig } from '../../'
65

76
test('reads single schema', t => {

src/__tests__/yaml/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import test from 'ava'
2-
const schema = require('../schema.json')
32
import { getGraphQLProjectConfig } from '../../'
43

5-
test(async (t) => {
4+
test(async t => {
65
const config = getGraphQLProjectConfig(__dirname)
76
const resolvedSchema = await config.resolveIntrospection()
87

9-
t.deepEqual(resolvedSchema, schema)
8+
t.snapshot(resolvedSchema)
109
})

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,11 +1370,11 @@ graphql-request@^1.5.0:
13701370
dependencies:
13711371
cross-fetch "1.1.1"
13721372

1373-
graphql@0.13.2:
1374-
version "0.13.2"
1375-
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.13.2.tgz#4c740ae3c222823e7004096f832e7b93b2108270"
1373+
graphql@14.0.2:
1374+
version "14.0.2"
1375+
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.0.2.tgz#7dded337a4c3fd2d075692323384034b357f5650"
13761376
dependencies:
1377-
iterall "^1.2.1"
1377+
iterall "^1.2.2"
13781378

13791379
har-schema@^1.0.5:
13801380
version "1.0.5"
@@ -1703,7 +1703,7 @@ isstream@~0.1.2:
17031703
version "0.1.2"
17041704
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
17051705

1706-
iterall@^1.2.1:
1706+
iterall@^1.2.2:
17071707
version "1.2.2"
17081708
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.2.2.tgz#92d70deb8028e0c39ff3164fdbf4d8b088130cd7"
17091709

0 commit comments

Comments
 (0)