diff --git a/.c8rc.json b/.c8rc.json index 100c6202c9..22bb450ee4 100644 --- a/.c8rc.json +++ b/.c8rc.json @@ -7,6 +7,7 @@ "src/jsutils/Maybe.ts", "src/jsutils/ObjMap.ts", "src/jsutils/PromiseOrValue.ts", + "src/utilities/assertValidName.ts", "src/utilities/typedQueryDocumentNode.ts" ], "clean": true, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ca73dfb05..029459e1a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,11 +166,14 @@ jobs: benchmark: name: Run benchmark runs-on: ubuntu-latest + env: + COMMITS_TO_TEST: ${{ github.event.pull_request.commits || 1 }} steps: - name: Checkout repo uses: actions/checkout@v2 - with: - fetch-depth: 2 + + - name: Deepen cloned repo + run: 'git fetch --deepen=$COMMITS_TO_TEST' - name: Setup Node.js uses: actions/setup-node@v2 @@ -182,16 +185,19 @@ jobs: run: npm ci --ignore-scripts - name: Run Benchmark - run: 'npm run benchmark -- --revs HEAD HEAD~1' + run: 'npm run benchmark -- --revs HEAD "HEAD~$COMMITS_TO_TEST"' diff-npm-package: name: Diff content of NPM package runs-on: ubuntu-latest + env: + COMMITS_TO_TEST: ${{ github.event.pull_request.commits || 1 }} steps: - name: Checkout repo uses: actions/checkout@v2 - with: - fetch-depth: 2 + + - name: Deepen cloned repo + run: 'git fetch --deepen=$COMMITS_TO_TEST' - name: Setup Node.js uses: actions/setup-node@v2 @@ -203,9 +209,7 @@ jobs: run: npm ci --ignore-scripts - name: Generate report - run: 'node resources/diff-npm-package.js $BASE_COMMIT HEAD' - env: - BASE_COMMIT: ${{ github.event.pull_request.base.sha || 'HEAD~1' }} + run: 'node resources/diff-npm-package.js HEAD~$COMMITS_TO_TEST HEAD' - name: Upload generated report uses: actions/upload-artifact@v2 diff --git a/package-lock.json b/package-lock.json index d719d644fd..3de5f1774f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "graphql", - "version": "16.1.0", + "version": "16.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "graphql", - "version": "16.1.0", + "version": "16.2.0", "license": "MIT", "devDependencies": { "@babel/core": "7.16.0", diff --git a/package.json b/package.json index 99eb587c9c..e5b5fb793d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphql", - "version": "16.1.0", + "version": "16.2.0", "description": "A Query Language and Runtime which can target any service.", "license": "MIT", "private": true, diff --git a/resources/build-deno.js b/resources/build-deno.js index b416e35c3b..f0479a858a 100644 --- a/resources/build-deno.js +++ b/resources/build-deno.js @@ -4,13 +4,12 @@ const fs = require('fs'); const path = require('path'); const babel = require('@babel/core'); -const prettier = require('prettier'); -const { readdirRecursive, showDirStats } = require('./utils.js'); - -const prettierConfig = JSON.parse( - fs.readFileSync(require.resolve('../.prettierrc'), 'utf-8'), -); +const { + writeGeneratedFile, + readdirRecursive, + showDirStats, +} = require('./utils.js'); if (require.main === module) { fs.rmSync('./denoDist', { recursive: true, force: true }); @@ -34,8 +33,3 @@ if (require.main === module) { showDirStats('./denoDist'); } - -function writeGeneratedFile(filepath, body) { - const formatted = prettier.format(body, { filepath, ...prettierConfig }); - fs.writeFileSync(filepath, formatted); -} diff --git a/resources/build-npm.js b/resources/build-npm.js index fe5e372f5e..7ff0cf079c 100644 --- a/resources/build-npm.js +++ b/resources/build-npm.js @@ -6,13 +6,12 @@ const assert = require('assert'); const ts = require('typescript'); const babel = require('@babel/core'); -const prettier = require('prettier'); -const { readdirRecursive, showDirStats } = require('./utils.js'); - -const prettierConfig = JSON.parse( - fs.readFileSync(require.resolve('../.prettierrc'), 'utf-8'), -); +const { + writeGeneratedFile, + readdirRecursive, + showDirStats, +} = require('./utils.js'); if (require.main === module) { fs.rmSync('./npmDist', { recursive: true, force: true }); @@ -90,11 +89,6 @@ if (require.main === module) { showDirStats('./npmDist'); } -function writeGeneratedFile(filepath, body) { - const formatted = prettier.format(body, { filepath, ...prettierConfig }); - fs.writeFileSync(filepath, formatted); -} - function babelBuild(srcPath, options) { const { code } = babel.transformFileSync(srcPath, { babelrc: false, diff --git a/resources/gen-version.js b/resources/gen-version.js index 944b51401d..b73621bce7 100644 --- a/resources/gen-version.js +++ b/resources/gen-version.js @@ -1,9 +1,9 @@ 'use strict'; -const fs = require('fs'); - const { version } = require('../package.json'); +const { writeGeneratedFile } = require('./utils.js'); + const versionMatch = /^(\d+)\.(\d+)\.(\d+)-?(.*)?$/.exec(version); if (!versionMatch) { throw new Error('Version does not match semver spec: ' + version); @@ -34,5 +34,5 @@ export const versionInfo = Object.freeze({ `; if (require.main === module) { - fs.writeFileSync('./src/version.ts', body.trim() + '\n'); + writeGeneratedFile('./src/version.ts', body); } diff --git a/resources/utils.js b/resources/utils.js index 253212c2d6..37cd83e801 100644 --- a/resources/utils.js +++ b/resources/utils.js @@ -4,6 +4,8 @@ const fs = require('fs'); const path = require('path'); const childProcess = require('child_process'); +const prettier = require('prettier'); + function exec(command, options) { const output = childProcess.execSync(command, { maxBuffer: 10 * 1024 * 1024, // 10MB @@ -80,8 +82,18 @@ function showDirStats(dirPath) { ); } +const prettierConfig = JSON.parse( + fs.readFileSync(require.resolve('../.prettierrc'), 'utf-8'), +); + +function writeGeneratedFile(filepath, body) { + const formatted = prettier.format(body, { filepath, ...prettierConfig }); + fs.writeFileSync(filepath, formatted); +} + module.exports = { exec, readdirRecursive, showDirStats, + writeGeneratedFile, }; diff --git a/src/execution/collectFields.ts b/src/execution/collectFields.ts index 396745d554..134000caec 100644 --- a/src/execution/collectFields.ts +++ b/src/execution/collectFields.ts @@ -22,11 +22,11 @@ import { typeFromAST } from '../utilities/typeFromAST'; import { getDirectiveValues } from './values'; /** - * Given a selectionSet, collect all of the fields and returns it at the end. + * Given a selectionSet, collects all of the fields and returns them. * - * CollectFields requires the "runtime type" of an object. For a field which + * CollectFields requires the "runtime type" of an object. For a field that * returns an Interface or Union type, the "runtime type" will be the actual - * Object type returned by that field. + * object type returned by that field. * * @internal */ @@ -52,11 +52,11 @@ export function collectFields( /** * Given an array of field nodes, collects all of the subfields of the passed - * in fields, and returns it at the end. + * in fields, and returns them at the end. * - * CollectFields requires the "return type" of an object. For a field which + * CollectSubFields requires the "return type" of an object. For a field that * returns an Interface or Union type, the "return type" will be the actual - * Object type returned by that field. + * object type returned by that field. * * @internal */ diff --git a/src/index.ts b/src/index.ts index 844ecaf5a2..fddd884198 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,6 +33,8 @@ export { graphql, graphqlSync } from './graphql'; /** Create and operate on GraphQL type definitions and schema. */ export { + resolveObjMapThunk, + resolveReadonlyArrayThunk, /** Definitions */ GraphQLSchema, GraphQLDirective, diff --git a/src/type/__tests__/assertName-test.ts b/src/type/__tests__/assertName-test.ts index 5bc1a12b83..4baf79c763 100644 --- a/src/type/__tests__/assertName-test.ts +++ b/src/type/__tests__/assertName-test.ts @@ -2,10 +2,8 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { assertName, assertEnumValueName } from '../assertName'; -import { assertValidName } from '../../utilities/assertValidName'; -describe('assertValidName()', () => { - assertValidName('test'); +describe('assertName', () => { it('passthrough valid name', () => { expect(assertName('_ValidName123')).to.equal('_ValidName123'); }); @@ -34,7 +32,7 @@ describe('assertValidName()', () => { }); }); -describe('assertEnumValueName()', () => { +describe('assertEnumValueName', () => { it('passthrough valid name', () => { expect(assertEnumValueName('_ValidName123')).to.equal('_ValidName123'); }); diff --git a/src/type/definition.ts b/src/type/definition.ts index ed658a8fc7..9a4fec2951 100644 --- a/src/type/definition.ts +++ b/src/type/definition.ts @@ -532,13 +532,13 @@ export function getNamedType( export type ThunkReadonlyArray = (() => ReadonlyArray) | ReadonlyArray; export type ThunkObjMap = (() => ObjMap) | ObjMap; -function resolveReadonlyArrayThunk( +export function resolveReadonlyArrayThunk( thunk: ThunkReadonlyArray, ): ReadonlyArray { return typeof thunk === 'function' ? thunk() : thunk; } -function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap { +export function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap { return typeof thunk === 'function' ? thunk() : thunk; } diff --git a/src/type/index.ts b/src/type/index.ts index 220412c4f0..72f24be4d6 100644 --- a/src/type/index.ts +++ b/src/type/index.ts @@ -11,6 +11,8 @@ export { export type { GraphQLSchemaConfig, GraphQLSchemaExtensions } from './schema'; export { + resolveObjMapThunk, + resolveReadonlyArrayThunk, /** Predicates */ isType, isScalarType, diff --git a/src/version.ts b/src/version.ts index 73a332fd10..f1f2c1b6c3 100644 --- a/src/version.ts +++ b/src/version.ts @@ -4,14 +4,14 @@ /** * A string containing the version of the GraphQL.js library */ -export const version = '16.1.0' as string; +export const version = '16.2.0' as string; /** * An object containing the components of the GraphQL.js version string */ export const versionInfo = Object.freeze({ major: 16 as number, - minor: 1 as number, + minor: 2 as number, patch: 0 as number, preReleaseTag: null as string | null, });