Skip to content

Commit

Permalink
CI improvements and GraphQL v16 support (#1930)
Browse files Browse the repository at this point in the history
* Improve CI

* Improve CI

* Add missing script

* Add tscheck script

* :)

* Fix lint

* Fix v14

* Fix match-graphql

* :))

* Skip federation testts for non v15

* Fix for v16

* Bump wrap

* Improve CI cache

* Add changeset

* Ignore node version in benchmark
  • Loading branch information
ardatan committed Oct 27, 2021
1 parent e78abcc commit 75552e6
Show file tree
Hide file tree
Showing 23 changed files with 1,487 additions and 376 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-hounds-trade.md
@@ -0,0 +1,5 @@
---
'graphql-modules': minor
---

feat: GraphQL v16 support
9 changes: 5 additions & 4 deletions .github/workflows/benchmark.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [12, 16]
node_version: [12, 17]
env:
CI: true

Expand All @@ -26,13 +26,14 @@ jobs:
name: Cache node_modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-${{ matrix.node_version }}-15-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ matrix.node_version }}
${{ runner.os }}-yarn-${{ matrix.node_version }}-15-
${{ runner.os }}-yarn-${{ matrix.node_version }}-
${{ runner.os }}-yarn-
- name: Install
run: yarn
run: yarn --ignore-engines

- name: Build
run: yarn build
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/canary.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: 17
- name: Configure Git Credentials
run: |
git config --global user.email "theguild-bot@users.noreply.github.com"
Expand All @@ -32,9 +32,10 @@ jobs:
name: Cache node_modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-14-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-17-15-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-14
${{ runner.os }}-yarn-17-15
${{ runner.os }}-yarn-17
${{ runner.os }}-yarn-
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/ci.yml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: 17
- name: Setup NPM credentials
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
Expand All @@ -35,9 +35,10 @@ jobs:
name: Cache node_modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-14-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-17-15-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-14
${{ runner.os }}-yarn-17-15-
${{ runner.os }}-yarn-17-
${{ runner.os }}-yarn-
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,122 @@
name: Tests

on:
push:
branches:
- master
pull_request: {}

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: 17
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-17-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-17-15-yarn
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Lint
run: yarn lint
build:
name: Type Check on GraphQL v${{matrix.graphql_version}}
runs-on: ubuntu-latest
strategy:
matrix:
graphql_version:
- 14
- 15
- 16.0.0-rc.7
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: 17
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-17-${{matrix.graphql_version}}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-17-${{matrix.graphql_version}}-yarn-
- name: Use GraphQL v${{matrix.graphql_version}}
run: node ./scripts/match-graphql.js ${{matrix.graphql_version}}
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Type Check
run: yarn ts:check
test:
name: Unit Test on Node ${{matrix.node-version}} (${{matrix.os}}) and GraphQL v${{matrix.graphql_version}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest] # remove windows to speed up the tests
node-version: [12, 17]
graphql_version:
- 14
- 15
- 16.0.0-rc.7
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-yarn-
- name: Use GraphQL v${{matrix.graphql_version}}
run: node ./scripts/match-graphql.js ${{matrix.graphql_version}}
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Cache Jest
uses: actions/cache@v2
with:
path: .cache/jest
key: ${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-jest-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-jest-
- name: Test
run: yarn test --ci
env:
CI: true
test_esm:
name: ESM Test
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: 17
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-17-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-17-15-yarn-
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Build Packages
run: yarn build
- name: Test ESM
run: node scripts/test-esm.mjs
13 changes: 13 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,13 @@
{
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/node_modules": true,
"test-lib": true,
"lib": true,
"coverage": true,
"npm": true,
"**/dist": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
15 changes: 15 additions & 0 deletions babel.config.js
@@ -0,0 +1,15 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{ targets: { node: process.versions.node.split('.')[0] } },
],
'@babel/preset-typescript',
],
plugins: [
'babel-plugin-transform-typescript-metadata',
['@babel/plugin-proposal-decorators', { legacy: true }],
'babel-plugin-parameter-decorator',
'@babel/plugin-proposal-class-properties',
],
};
7 changes: 0 additions & 7 deletions jest.config.base.js
Expand Up @@ -9,15 +9,8 @@ const CI = !!process.env.CI;

module.exports = (dir) => {
return {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: dir,
globals: {
'ts-jest': {
diagnostics: false,
tsconfig: TSCONFIG_TEST_PATH,
},
},
reporters: ['default'],
modulePathIgnorePatterns: ['dist'],
moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
Expand Down
13 changes: 11 additions & 2 deletions package.json
Expand Up @@ -9,19 +9,25 @@
],
"scripts": {
"postinstall": "patch-package",
"ts:check": "tsc --project tsconfig.json --noEmit",
"build": "tsc --project tsconfig.json && bob build",
"test": "jest",
"prerelease": "yarn build",
"release": "changeset publish",
"release:canary": "(node scripts/canary-release.js && yarn build && yarn changeset publish --tag alpha) || echo Skipping Canary...",
"format": "prettier --write \"packages/**/*.{js,json,css,md,ts,tsx}\"",
"pr": "changeset",
"lint": "eslint \"packages/**\"",
"lint": "eslint \"packages/**/*.{js,jsx,ts,tsx}\"",
"benchmark:basic": "NODE_ENV=production ts-node --project tsconfig.app.json benchmark/basic.case.ts",
"deploy-website": "cd website && yarn && yarn build && mkdir graphql-modules && mv build/* graphql-modules && mv graphql-modules build"
},
"devDependencies": {
"@apollo/federation": "0.33.3",
"@babel/core": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/preset-typescript": "7.15.0",
"@babel/plugin-proposal-decorators": "7.15.8",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@changesets/apply-release-plan": "5.0.1",
"@changesets/cli": "2.17.0",
"@graphql-tools/merge": "8.2.1",
Expand All @@ -36,14 +42,17 @@
"apollo-server-express": "3.4.0",
"artillery": "1.7.9",
"benchmark": "2.1.4",
"babel-plugin-parameter-decorator": "1.0.16",
"babel-plugin-transform-typescript-metadata": "0.3.2",
"babel-jest": "27.3.1",
"bob-the-bundler": "1.5.1",
"chalk": "4.1.2",
"dataloader": "2.0.0",
"eslint": "7.32.0",
"express": "4.17.1",
"express-graphql": "0.11.0",
"globby": "11.0.4",
"graphql": "15.7.0",
"graphql": "15.7.1",
"graphql-subscriptions": "1.2.1",
"husky": "7.0.4",
"jest": "27.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-modules/package.json
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@graphql-tools/schema": "^8.1.1",
"@graphql-tools/wrap": "^8.0.12",
"@graphql-tools/wrap": "^8.3.1",
"@graphql-typed-document-node/core": "^3.1.0",
"ramda": "^0.27.1"
},
Expand Down
8 changes: 5 additions & 3 deletions packages/graphql-modules/src/application/apollo.ts
Expand Up @@ -24,7 +24,9 @@ export function apolloExecutorCreator({
}): Application['createApolloExecutor'] {
return function createApolloExecutor(options) {
const executor = createExecution(options);
return async function executorAdapter(requestContext: ApolloRequestContext) {
return async function executorAdapter(
requestContext: ApolloRequestContext
) {
return executor({
schema: requestContext.schema,
document: requestContext.document,
Expand Down Expand Up @@ -91,7 +93,7 @@ export function apolloSchemaCreator({
return subscription({
schema,
document: input.document,
variableValues: input.variables,
variableValues: input.variables as any,
contextValue: input.context,
rootValue: input.rootValue,
operationName: input.operationName,
Expand All @@ -109,7 +111,7 @@ export function apolloSchemaCreator({
schema,
document: input.document,
contextValue: context,
variableValues: input.variables,
variableValues: input.variables as any,
rootValue: input.rootValue,
operationName: input.operationName,
}) as any
Expand Down

0 comments on commit 75552e6

Please sign in to comment.