diff --git a/package.json b/package.json index 18fbb51b6..63f5fedef 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@types/node-fetch": "1.6.7", "ava": "0.25.0", "cpx": "1.5.0", - "graphql": "0.13.2", + "graphql": "14.0.2", "rimraf": "2.6.2", "tslint": "5.9.1", "tslint-config-standard": "7.0.0", diff --git a/src/__tests__/basic/findGraphQLConfigFile.ts b/src/__tests__/basic/findGraphQLConfigFile.ts index 67fdede5f..90abfe986 100644 --- a/src/__tests__/basic/findGraphQLConfigFile.ts +++ b/src/__tests__/basic/findGraphQLConfigFile.ts @@ -2,20 +2,27 @@ import test from 'ava' import { dirname, join } from 'path' import { mkdtempSync } from 'fs' import { tmpdir } from 'os' -const schema = require('../schema.json') import { findGraphQLConfigFile, ConfigNotFoundError } from '../../' -test('returns a correct config filename', (t) => { +test('returns a correct config filename', t => { const configFile = findGraphQLConfigFile(__dirname) t.deepEqual(configFile, join(__dirname, '.graphqlconfig')) -}); +}) -test('returns a correct config filename for 1st level of sub directories', (t) => { - const configFile = findGraphQLConfigFile(`${__dirname}/../sub-directory-config`) - t.deepEqual(configFile, join(`${__dirname}/../sub-directory-config/sub-directory-2`, '.graphqlconfig')) -}); +test('returns a correct config filename for 1st level of sub directories', t => { + const configFile = findGraphQLConfigFile( + `${__dirname}/../sub-directory-config`, + ) + t.deepEqual( + configFile, + join( + `${__dirname}/../sub-directory-config/sub-directory-2`, + '.graphqlconfig', + ), + ) +}) -test('throws GraphQLConfigNotFoundError when config is not found', (t) => { +test('throws GraphQLConfigNotFoundError when config is not found', t => { const tempDir = mkdtempSync(join(tmpdir(), 'graphql-config')) t.throws(() => findGraphQLConfigFile(tempDir), ConfigNotFoundError) }) diff --git a/src/__tests__/basic/getGraphQLConfig.ts b/src/__tests__/basic/getGraphQLConfig.ts index 87118f986..d3042498b 100644 --- a/src/__tests__/basic/getGraphQLConfig.ts +++ b/src/__tests__/basic/getGraphQLConfig.ts @@ -1,7 +1,6 @@ import test from 'ava' import { join, resolve } from 'path' import { printSchema } from 'graphql' -const schema = require('../schema.json') import { getGraphQLConfig, GraphQLConfig } from '../../' const CONFIG_DIR = join(__dirname, 'config') @@ -18,7 +17,9 @@ test('returns a correct name', t => { }) test('returns config for file', t => { - const testWithSchemaConfig = config.getConfigForFile(resolve('./config/schema-a.graphql')) + const testWithSchemaConfig = config.getConfigForFile( + resolve('./config/schema-a.graphql'), + ) if (testWithSchemaConfig) { t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema') } else { diff --git a/src/__tests__/basic/getGraphQLProjectConfig.ts b/src/__tests__/basic/getGraphQLProjectConfig.ts index ebb8b8e3e..110cc3e17 100644 --- a/src/__tests__/basic/getGraphQLProjectConfig.ts +++ b/src/__tests__/basic/getGraphQLProjectConfig.ts @@ -1,10 +1,9 @@ import test from 'ava' -const schema = require('../schema.json') import { getGraphQLProjectConfig } from '../../' -test('resolves schema from file', async (t) => { +test('resolves schema from file', async t => { const config = getGraphQLProjectConfig(__dirname) const resolvedSchema = await config.resolveIntrospection() - t.deepEqual(resolvedSchema, schema) + t.snapshot(resolvedSchema) }) diff --git a/src/__tests__/endpoint-extension/resolve.ts b/src/__tests__/endpoint-extension/resolve.ts index 01f5bcc48..d1db38224 100644 --- a/src/__tests__/endpoint-extension/resolve.ts +++ b/src/__tests__/endpoint-extension/resolve.ts @@ -1,17 +1,15 @@ import test from 'ava' import { graphql, introspectionQuery } from 'graphql' -import { GraphQLProjectConfig, GraphQLEndpointsExtension } from '../../' +import { GraphQLProjectConfig } from '../../' import { serveSchema } from '../utils' -const introspection = require('../schema.json') -test.before(async (t) => { +test.before(async t => { return await serveSchema() }) - const confPath = `${__dirname}/.graphqlconfig` -test('getEndpointsMap when endpoint is string url', async (t) => { +test('getEndpointsMap when endpoint is string url', async t => { const configData = { schemaPath: '../schema.json', extensions: { @@ -23,10 +21,12 @@ test('getEndpointsMap when endpoint is string url', async (t) => { const config = new GraphQLProjectConfig(configData, confPath) const endpoints = config.endpointsExtension - t.deepEqual(endpoints && endpoints.getRawEndpointsMap(), { dev: { url: 'http://default' }}) + t.deepEqual(endpoints && endpoints.getRawEndpointsMap(), { + dev: { url: 'http://default' }, + }) }) -test('getEndpointsMap when endpoint is single endpoint config', async (t) => { +test('getEndpointsMap when endpoint is single endpoint config', async t => { const configData = { schemaPath: '../schema.json', extensions: { @@ -43,10 +43,12 @@ test('getEndpointsMap when endpoint is single endpoint config', async (t) => { const config = new GraphQLProjectConfig(configData, confPath, undefined) const endpoint = config.endpointsExtension - t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { dev: configData.extensions.endpoints.dev }) + t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { + dev: configData.extensions.endpoints.dev, + }) }) -test('getEndpointsMap when endpoint is endpoints map', async (t) => { +test('getEndpointsMap when endpoint is endpoints map', async t => { const configData = { schemaPath: '../schema.json', extensions: { @@ -65,22 +67,20 @@ test('getEndpointsMap when endpoint is endpoints map', async (t) => { const config = new GraphQLProjectConfig(configData, confPath, undefined) const endpoint = config.endpointsExtension - t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), - { - dev: { - url: 'http://dev', + t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { + dev: { + url: 'http://dev', + }, + prod: { + url: 'http://prod', + subscription: { + url: 'ws://prod', }, - prod: { - url: 'http://prod', - subscription: { - url: 'ws://prod', - }, - } - } - ) + }, + }) }) -test('resolveSchemaFromEndpoint should throw if non-existing endpoint is specified', async (t) => { +test('resolveSchemaFromEndpoint should throw if non-existing endpoint is specified', async t => { const configData = { schemaPath: '../schema.json', extensions: { @@ -97,25 +97,32 @@ test('resolveSchemaFromEndpoint should throw if non-existing endpoint is specifi const config = new GraphQLProjectConfig(configData, confPath, undefined) let error const endpoint = config.endpointsExtension - error = t.throws(() => endpoint && endpoint.getEndpoint('prod').resolveSchema()) - t.regex(error.message, /"prod" is not valid endpoint name. Valid endpoint names: dev/) + error = t.throws( + () => endpoint && endpoint.getEndpoint('prod').resolveSchema(), + ) + t.regex( + error.message, + /"prod" is not valid endpoint name. Valid endpoint names: dev/, + ) }) -test('resolveSchemaFromEndpoint HTTP', async (t) => { +test('resolveSchemaFromEndpoint HTTP', async t => { const configData = { schemaPath: '../schema.json', extensions: { endpoints: { - dev: 'http://127.0.0.1:33333' - } + dev: 'http://127.0.0.1:33333', + }, }, } const config = new GraphQLProjectConfig(configData, confPath, undefined) - if (!config.endpointsExtension){ + if (!config.endpointsExtension) { throw 'endpointExtension can\'t be empty' } - const schema = await config.endpointsExtension.getEndpoint('dev').resolveSchema() + const schema = await config.endpointsExtension + .getEndpoint('dev') + .resolveSchema() const resolvedIntrospection = await graphql(schema, introspectionQuery) - t.deepEqual(resolvedIntrospection, introspection) + t.snapshot(resolvedIntrospection) }) diff --git a/src/__tests__/introspection-query/getSchema.ts b/src/__tests__/introspection-query/getSchema.ts index d78e57e53..cf55a7fe6 100644 --- a/src/__tests__/introspection-query/getSchema.ts +++ b/src/__tests__/introspection-query/getSchema.ts @@ -1,7 +1,6 @@ import test from 'ava' import { join } from 'path' import { printSchema } from 'graphql' -const schema = require('../schema.json') import { getGraphQLConfig, GraphQLConfig } from '../../' test('reads single schema', t => { diff --git a/src/__tests__/yaml/test.ts b/src/__tests__/yaml/test.ts index 5136ba6e1..e9da8730e 100644 --- a/src/__tests__/yaml/test.ts +++ b/src/__tests__/yaml/test.ts @@ -1,10 +1,9 @@ import test from 'ava' -const schema = require('../schema.json') import { getGraphQLProjectConfig } from '../../' -test(async (t) => { +test(async t => { const config = getGraphQLProjectConfig(__dirname) const resolvedSchema = await config.resolveIntrospection() - t.deepEqual(resolvedSchema, schema) + t.snapshot(resolvedSchema) }) diff --git a/yarn.lock b/yarn.lock index 492148517..a06216f1b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1370,11 +1370,11 @@ graphql-request@^1.5.0: dependencies: cross-fetch "1.1.1" -graphql@0.13.2: - version "0.13.2" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.13.2.tgz#4c740ae3c222823e7004096f832e7b93b2108270" +graphql@14.0.2: + version "14.0.2" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.0.2.tgz#7dded337a4c3fd2d075692323384034b357f5650" dependencies: - iterall "^1.2.1" + iterall "^1.2.2" har-schema@^1.0.5: version "1.0.5" @@ -1703,7 +1703,7 @@ isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -iterall@^1.2.1: +iterall@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.2.2.tgz#92d70deb8028e0c39ff3164fdbf4d8b088130cd7"