Skip to content

Commit

Permalink
Merge branch 'master' into reproduction-print-with-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored Jul 14, 2021
2 parents 8f18f4d + 9c26b84 commit 205a9ab
Show file tree
Hide file tree
Showing 178 changed files with 7,000 additions and 2,523 deletions.
20 changes: 20 additions & 0 deletions .changeset/blue-ducks-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@graphql-tools/load': major
'@graphql-tools/apollo-engine-loader': major
'@graphql-tools/code-file-loader': major
'@graphql-tools/git-loader': major
'@graphql-tools/github-loader': major
'@graphql-tools/graphql-file-loader': major
'@graphql-tools/json-file-loader': major
'@graphql-tools/module-loader': major
'@graphql-tools/url-loader': major
'@graphql-tools/utils': major
---

BREAKING CHANGE

- Now each loader handles glob patterns internally and returns an array of `Source` object instead of single `Source`

- GraphQL Tag Pluck now respects code locations and returns graphql-js `Source` objects for each found code block

- Thanks to the one above, `CodeFileLoader` now returns different `Source` objects for each found SDL code block.
5 changes: 5 additions & 0 deletions .changeset/cool-onions-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': minor
---

enhance(loaders): remove optional methods from the Loader interface
24 changes: 24 additions & 0 deletions .changeset/fresh-queens-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@graphql-tools/batch-delegate': major
'@graphql-tools/batch-execute': major
'@graphql-tools/delegate': major
'@graphql-tools/links': major
'@graphql-tools/url-loader': major
'@graphql-tools/stitch': major
'@graphql-tools/utils': major
'@graphql-tools/wrap': major
---

refactor: ExecutionParams type replaced by Request type

rootValue property is now a part of the Request type.

When delegating with delegateToSchema, rootValue can be set multiple ways:

- when using a custom executor, the custom executor can utilize a rootValue in whichever custom way it specifies.
- when using the default executor (execute/subscribe from graphql-js):
-- rootValue can be passed to delegateToSchema via a named option
-- rootValue can be included within a subschemaConfig
-- otherwise, rootValue is inferred from the originating schema

When using wrapSchema/stitchSchemas, a subschemaConfig can specify the createProxyingResolver function which can pass whatever rootValue it wants to delegateToSchema as above.
8 changes: 8 additions & 0 deletions .changeset/green-rocks-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/utils': major
---

BREAKING CHANGES;

`mergeDeep` now takes an array of sources instead of set of parameters as input and it takes an additional flag to enable prototype merging
Instead of `mergeDeep(...sources)` => `mergeDeep(sources)`
5 changes: 5 additions & 0 deletions .changeset/khaki-balloons-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/code-file-loader': minor
---

include rawSDL in Source of plucked files
25 changes: 25 additions & 0 deletions .changeset/lazy-turtles-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
'@graphql-tools/batch-execute': major
'@graphql-tools/delegate': major
'@graphql-tools/links': major
'@graphql-tools/utils': major
'@graphql-tools/wrap': major
---

BREAKING CHANGES;

- Rename `Request` to `ExecutionRequest`
- Drop unnecessary `GraphQLResolveInfo` in `ExecutionRequest`
- Add required `operationType: OperationTypeNode` field in `ExecutionRequest`
- Add `context` in `createRequest` and `createRequestInfo` instead of `delegateToSchema`

> It doesn't rely on info.operation.operationType to allow the user to call an operation from different root type.
And it doesn't call getOperationAST again and again to get operation type from the document/operation because we have it in Request and ExecutionParams
https://github.com/ardatan/graphql-tools/pull/3166/files#diff-d4824895ea613dcc1f710c3ac82e952fe0ca12391b671f70d9f2d90d5656fdceR38

Improvements;
- Memoize `defaultExecutor` for a single `GraphQLSchema` so allow `getBatchingExecutor` to memoize `batchingExecutor` correctly.
- And there is no different `defaultExecutor` is created for `subscription` and other operation types. Only one executor is used.

> Batch executor is memoized by `executor` reference but `createDefaultExecutor` didn't memoize the default executor so this memoization wasn't working correctly on `batch-execute` side.
https://github.com/ardatan/graphql-tools/blob/remove-info-executor/packages/batch-execute/src/getBatchingExecutor.ts#L9
5 changes: 5 additions & 0 deletions .changeset/metal-apes-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/code-file-loader': minor
---

allow supplying config via constructor
5 changes: 5 additions & 0 deletions .changeset/ninety-spies-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/graphql-tag-pluck': patch
---

ensure operations with GraphQL magic comment are only parsed once.
8 changes: 8 additions & 0 deletions .changeset/pretty-laws-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/code-file-loader': major
'@graphql-tools/git-loader': major
'@graphql-tools/graphql-file-loader': major
'@graphql-tools/load': patch
---

Loader.canLoad and Loader.canLoadSync can only handle file paths not glob patterns
16 changes: 16 additions & 0 deletions .changeset/quick-hotels-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@graphql-tools/stitch': major
'@graphql-tools/stitching-directives': major
'@graphql-tools/utils': major
'@graphql-tools/wrap': major
---

fix(getDirectives): preserve order around repeatable directives

BREAKING CHANGE: getDirectives now always return an array of individual DirectiveAnnotation objects consisting of `name` and `args` properties.

New useful function `getDirective` returns an array of objects representing any args for each use of a single directive (returning the empty object `{}` when a directive is used without arguments).

Note: The `getDirective` function returns an array even when the specified directive is non-repeatable. This is because one use of this function is to throw an error if more than one directive annotation is used for a non repeatable directive!

When specifying directives in extensions, one can use either the old or new format.
5 changes: 5 additions & 0 deletions .changeset/quiet-carrots-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/stitching-directives': minor
---

feat(stitching-directives): move federation-to-stitching-sdl
5 changes: 5 additions & 0 deletions .changeset/silver-comics-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/resolvers-composition': minor
---

Added glob pattern support for composeResolver method
5 changes: 5 additions & 0 deletions .changeset/unlucky-kangaroos-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/url-loader': patch
---

fix(url-loader): fix node support for EventSource
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ contact_links:
- name: Have a question?
url: https://github.com/ardatan/graphql-tools/discussions/new
about: Not sure about something? need help from the community? have a question to our team? please ask and answer questions here.
- name: Any issue with `npm audit`
url: https://overreacted.io/npm-audit-broken-by-design/
about: Please do not create issues about `npm audit` and you can contact with us directly for more questions.
53 changes: 53 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Benchmark

on:
pull_request:
branches:
- master

jobs:
federation-benchmark:
name: Federation Benchmark with ${{matrix.products_size}} Products
runs-on: ubuntu-latest
strategy:
matrix:
products_size: [3, 10, 50, 100, 1000]
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: 16
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-16-16-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-16-16-yarn
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Build
run: yarn build
- name: Setup K6
run: |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: GraphQL API
working-directory: ./benchmark/federation
run: |
yarn start &
yarn wait-on tcp:3000
env:
PRODUCTS_SIZE: ${{matrix.products_size}}
- name: Federation
run: k6 -e ENDPOINT=federation run --out json=federation.json benchmark/federation/k6.js
- name: Stitching
run: k6 -e ENDPOINT=stitching run --out json=stitching.json benchmark/federation/k6.js
- name: Monolith
run: k6 -e ENDPOINT=monolith run --out json=monolith.json benchmark/federation/k6.js
- name: Compare
run: node benchmark/compare monolith:monolith.json federation:federation.json stitching:stitching.json
69 changes: 69 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
35 changes: 35 additions & 0 deletions benchmark/compare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require('fs');
const path = require('path');
let [, , ...rawPointers] = process.argv;

function createReport(pointer) {
const [name, file] = pointer.split(':');

const lines = fs.readFileSync(path.join(process.cwd(), file), 'utf-8').split('\n');

let sum = 0;
let count = 0;

for (let line of lines) {
if (line.trim().length) {
const metric = JSON.parse(line);

if (metric.type === 'Point' && metric.metric === 'http_req_duration' && metric.data.tags.status === '200') {
count++;
sum += metric.data.value;
}
}
}

return {
name,
file,
avg: sum / count,
};
}

const pointers = rawPointers.map(createReport);

const stats = pointers.map(pointer => `${pointer.name}: ${pointer.avg.toFixed(2)} ms`).join('\n')

console.log(stats);
53 changes: 53 additions & 0 deletions benchmark/federation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# environment variables
.env
Loading

0 comments on commit 205a9ab

Please sign in to comment.