Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ardatan/graphql-tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @graphql-tools/utils@10.3.1
Choose a base ref
...
head repository: ardatan/graphql-tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @graphql-tools/utils@10.3.2
Choose a head ref
  • 12 commits
  • 13 files changed
  • 5 contributors

Commits on Jul 5, 2024

  1. chore(deps): update dependency @types/node to v20.14.10 (#6327)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 5, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    07d42ee View commit details

Commits on Jul 9, 2024

  1. chore(deps): update all non-major dependencies (#6330)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 9, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bdfbcec View commit details

Commits on Jul 10, 2024

  1. Strip ignored characters when printing a query in executor-http (#6332)

    kamilkisiela authored Jul 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7be6930 View commit details
  2. chore(deps): update dependency ts-jest to v29.2.1 (#6333)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9745d16 View commit details
  3. fix(deps): update dependency next to v14.2.5 (#6336)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    06c8057 View commit details
  4. chore(deps): update dependency ts-jest to v29.2.2 (#6337)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ef0ae03 View commit details

Commits on Jul 11, 2024

  1. chore(deps): update dependency puppeteer to v22.13.0 (#6338)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    904dc87 View commit details
  2. fix(deps): update dependency @theguild/components to v6.6.0 (#6340)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b25107f View commit details
  3. fix(deps): update all non-major dependencies (#6341)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e9a1fad View commit details

Commits on Jul 13, 2024

  1. chore(deps): update all non-major dependencies (#6342)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e07bb6d View commit details
  2. fix(pruneSchema): respect directive definitions in extensions

    ardatan committed Jul 13, 2024

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    a276ba8 View commit details
  3. chore(release): update monorepo packages versions (#6334)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    theguild-bot and github-actions[bot] authored Jul 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    791aebf View commit details
4 changes: 2 additions & 2 deletions benchmark/federation/package.json
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
"start": "cross-env NODE_ENV=production node index.js"
},
"dependencies": {
"@apollo/gateway": "2.8.2",
"@apollo/subgraph": "2.8.2",
"@apollo/gateway": "2.8.3",
"@apollo/subgraph": "2.8.3",
"@graphql-tools/federation": "2.1.1",
"@graphql-tools/stitch": "9.2.10",
"cross-env": "7.0.3",
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -45,24 +45,24 @@
"ts:check": "tsc --noEmit"
},
"devDependencies": {
"@babel/core": "7.24.7",
"@babel/core": "7.24.8",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/preset-env": "7.24.7",
"@babel/preset-env": "7.24.8",
"@babel/preset-typescript": "7.24.7",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.7",
"@theguild/prettier-config": "2.0.6",
"@types/debug": "4.1.12",
"@types/jest": "29.5.12",
"@types/node": "20.14.9",
"@types/node": "20.14.10",
"@typescript-eslint/eslint-plugin": "7.15.0",
"@typescript-eslint/parser": "7.15.0",
"babel-jest": "29.7.0",
"bob-the-bundler": "7.0.1",
"chalk": "4.1.2",
"concurrently": "8.2.2",
"cross-env": "7.0.3",
"eslint": "9.6.0",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.1",
@@ -78,7 +78,7 @@
"patch-package": "8.0.0",
"prettier": "3.3.2",
"prettier-plugin-tailwindcss": "0.6.5",
"ts-jest": "29.1.5",
"ts-jest": "29.2.2",
"ts-node": "10.9.2",
"typedoc": "0.25.13",
"typedoc-plugin-markdown": "3.16.0",
13 changes: 13 additions & 0 deletions packages/executors/http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @graphql-tools/executor-http

## 1.1.3

### Patch Changes

- [#6332](https://github.com/ardatan/graphql-tools/pull/6332)
[`7be6930`](https://github.com/ardatan/graphql-tools/commit/7be69305bb5f9e38c96c8372ac467aa43585da54)
Thanks [@kamilkisiela](https://github.com/kamilkisiela)! - Strip ignored characters when printing
a query in executor-http

- Updated dependencies
[[`a276ba8`](https://github.com/ardatan/graphql-tools/commit/a276ba83cf7e2aa1c0f81454591a794d6efb8c2a)]:
- @graphql-tools/utils@10.3.2

## 1.1.2

### Patch Changes
4 changes: 2 additions & 2 deletions packages/executors/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-tools/executor-http",
"version": "1.1.2",
"version": "1.1.3",
"type": "module",
"description": "A set of utils for faster development of GraphQL tools",
"repository": {
@@ -51,7 +51,7 @@
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "^10.3.1",
"@graphql-tools/utils": "^10.3.2",
"@repeaterjs/repeater": "^3.0.4",
"@whatwg-node/fetch": "^0.9.0",
"extract-files": "^11.0.0",
4 changes: 2 additions & 2 deletions packages/executors/http/src/defaultPrintFn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DocumentNode, print } from 'graphql';
import { DocumentNode, print, stripIgnoredCharacters } from 'graphql';

const printCache = new WeakMap<DocumentNode, string>();

export function defaultPrintFn(document: DocumentNode) {
let printed = printCache.get(document);
if (!printed) {
printed = print(document);
printed = stripIgnoredCharacters(print(document));
printCache.set(document, printed);
}
return printed;
6 changes: 3 additions & 3 deletions packages/graphql-tag-pluck/package.json
Original file line number Diff line number Diff line change
@@ -60,9 +60,9 @@
},
"devDependencies": {
"@astrojs/compiler": "^2.3.4",
"@babel/parser": "7.24.7",
"@babel/traverse": "7.24.7",
"@babel/types": "7.24.7",
"@babel/parser": "7.24.8",
"@babel/traverse": "7.24.8",
"@babel/types": "7.24.8",
"@types/babel__traverse": "7.20.6",
"@vue/compiler-sfc": "3.4.31",
"astrojs-compiler-sync": "^1.0.0",
4 changes: 2 additions & 2 deletions packages/loaders/url/package.json
Original file line number Diff line number Diff line change
@@ -77,9 +77,9 @@
"graphql-sse": "2.5.3",
"graphql-upload": "16.0.2",
"graphql-yoga": "5.6.0",
"puppeteer": "22.12.1",
"puppeteer": "22.13.0",
"subscriptions-transport-ws": "0.11.0",
"webpack": "5.92.1"
"webpack": "5.93.0"
},
"publishConfig": {
"directory": "dist",
7 changes: 7 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @graphql-tools/utils

## 10.3.2

### Patch Changes

- [`a276ba8`](https://github.com/ardatan/graphql-tools/commit/a276ba83cf7e2aa1c0f81454591a794d6efb8c2a)
Thanks [@ardatan](https://github.com/ardatan)! - Respect directive extensions on \`pruneSchema\`

## 10.3.1

### Patch Changes
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-tools/utils",
"version": "10.3.1",
"version": "10.3.2",
"type": "module",
"description": "Common package containing utils and types for GraphQL tools",
"repository": {
51 changes: 30 additions & 21 deletions packages/utils/src/prune.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ASTNode,
getNamedType,
GraphQLFieldMap,
GraphQLSchema,
@@ -11,6 +10,7 @@ import {
isSpecifiedScalarType,
isUnionType,
} from 'graphql';
import { DirectableGraphQLObject } from './get-directives.js';
import { getImplementingTypes } from './get-implementing-types.js';
import { MapperKind } from './Interfaces.js';
import { mapSchema } from './mapSchema.js';
@@ -152,12 +152,7 @@ function visitQueue(
if (isEnumType(type)) {
// Visit enum values directives argument types
queue.push(
...type.getValues().flatMap(value => {
if (value.astNode) {
return getDirectivesArgumentsTypeNames(schema, value.astNode);
}
return [];
}),
...type.getValues().flatMap(value => getDirectivesArgumentsTypeNames(schema, value)),
);
}
// Visit interfaces this type is implementing if they haven't been visited yet
@@ -180,9 +175,7 @@ function visitQueue(
queue.push(
...field.args.flatMap(arg => {
const typeNames = [getNamedType(arg.type).name];
if (arg.astNode) {
typeNames.push(...getDirectivesArgumentsTypeNames(schema, arg.astNode));
}
typeNames.push(...getDirectivesArgumentsTypeNames(schema, arg));
return typeNames;
}),
);
@@ -192,9 +185,7 @@ function visitQueue(

queue.push(namedType.name);

if (field.astNode) {
queue.push(...getDirectivesArgumentsTypeNames(schema, field.astNode));
}
queue.push(...getDirectivesArgumentsTypeNames(schema, field));

// Interfaces returned on fields need to be revisited to add their implementations
if (isInterfaceType(namedType) && !(namedType.name in revisit)) {
@@ -203,9 +194,7 @@ function visitQueue(
}
}

if (type.astNode) {
queue.push(...getDirectivesArgumentsTypeNames(schema, type.astNode));
}
queue.push(...getDirectivesArgumentsTypeNames(schema, type));

visited.add(typeName); // Mark as visited (and therefore it is used and should be kept)
}
@@ -215,10 +204,30 @@ function visitQueue(

function getDirectivesArgumentsTypeNames(
schema: GraphQLSchema,
astNode: Extract<ASTNode, { readonly directives?: any }>,
directableObj: DirectableGraphQLObject,
) {
return (astNode.directives ?? []).flatMap(
directive =>
schema.getDirective(directive.name.value)?.args.map(arg => getNamedType(arg.type).name) ?? [],
);
const argTypeNames = new Set<string>();
if (directableObj.astNode?.directives) {
for (const directiveNode of directableObj.astNode.directives) {
const directive = schema.getDirective(directiveNode.name.value);
if (directive?.args) {
for (const arg of directive.args) {
const argType = getNamedType(arg.type);
argTypeNames.add(argType.name);
}
}
}
}
if (directableObj.extensions?.['directives']) {
for (const directiveName in directableObj.extensions['directives']) {
const directive = schema.getDirective(directiveName);
if (directive?.args) {
for (const arg of directive.args) {
const argType = getNamedType(arg.type);
argTypeNames.add(argType.name);
}
}
}
}
return [...argTypeNames];
}
54 changes: 53 additions & 1 deletion packages/utils/tests/prune.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { buildSchema, GraphQLNamedType } from 'graphql';
import {
buildSchema,
DirectiveLocation,
GraphQLDirective,
GraphQLEnumType,
GraphQLNamedType,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
} from 'graphql';
import { PruneSchemaFilter } from '../src/index.js';
import { pruneSchema } from '../src/prune.js';

@@ -487,6 +496,49 @@ describe('pruneSchema', () => {
}
`);

const result = pruneSchema(schema);
expect(result.getType('DirectiveArg')).toBeDefined();
});
test('does not remove type used in argument definition directive argument from extensions', () => {
const enumType = new GraphQLEnumType({
name: 'DirectiveArg',
values: {
VALUE: {
value: 'VALUE',
},
},
});
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
foo: {
type: GraphQLString,
extensions: {
directives: {
bar: [
{
arg: 'VALUE',
},
],
},
},
},
},
}),
directives: [
new GraphQLDirective({
name: 'bar',
locations: [DirectiveLocation.FIELD],
args: {
arg: {
type: enumType,
},
},
}),
],
});

const result = pruneSchema(schema);
expect(result.getType('DirectiveArg')).toBeDefined();
});
6 changes: 3 additions & 3 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@
"start": "next start"
},
"dependencies": {
"@theguild/components": "6.5.3",
"next": "14.2.4",
"@theguild/components": "6.6.0",
"next": "14.2.5",
"next-sitemap": "4.2.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@theguild/tailwind-config": "0.4.2",
"@types/node": "20.14.9",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"typescript": "5.4.5"
}
Loading