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/load-files@6.3.0
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/load-files@6.3.1
Choose a head ref
  • 8 commits
  • 16 files changed
  • 7 contributors

Commits on Mar 9, 2021

  1. fix(deps): update dependency relay-compiler to v11 (#2713)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c019bc5 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7852494 View commit details
  3. Fix pruneSchema for unimplemented interfaces (#2714)

    * Add test for unimplemented interfaces
    
    * Add changeset
    
    Co-authored-by: Shane Myrick <accounts@shanemyrick.com>
    smyrick and Shane Myrick authored Mar 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    de16fff View commit details
  4. chore(release): update monorepo packages versions (#2715)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Mar 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    275df3a View commit details
  5. chore(deps): update dependency @types/node to v14.14.33 (#2716)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b987e4e View commit details

Commits on Mar 10, 2021

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    e77692c View commit details
  2. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    61889f2 View commit details
  3. chore(release): update monorepo packages versions (#2719)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Mar 10, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8355d2f View commit details
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,9 @@
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Related # (issue)
<!--
Please do not use "Fixed" or "Resolves". Keep "Related" as-is.
-->

## Type of change

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
"@babel/plugin-proposal-class-properties": "7.13.0",
"@changesets/cli": "2.14.0",
"@types/jest": "26.0.20",
"@types/node": "14.14.32",
"@types/node": "14.14.33",
"@typescript-eslint/eslint-plugin": "4.17.0",
"@typescript-eslint/parser": "4.17.0",
"@ardatan/bob-the-bundler": "1.2.2",
2 changes: 1 addition & 1 deletion packages/batch-delegate/package.json
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
"devDependencies": {
"@graphql-tools/schema": "7.1.3",
"@graphql-tools/stitch": "7.4.0",
"@graphql-tools/utils": "7.5.1"
"@graphql-tools/utils": "7.5.2"
},
"publishConfig": {
"access": "public",
6 changes: 6 additions & 0 deletions packages/load-files/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @graphql-tools/load-files

## 6.3.1

### Patch Changes

- 61889f28: fix(load-files): respect ignoredExtensions even if there is a specific file glob

## 6.3.0

### Minor Changes
2 changes: 1 addition & 1 deletion packages/load-files/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-tools/load-files",
"version": "6.3.0",
"version": "6.3.1",
"description": "A set of utils for faster development of GraphQL tools",
"repository": {
"type": "git",
11 changes: 10 additions & 1 deletion packages/load-files/src/index.ts
Original file line number Diff line number Diff line change
@@ -182,7 +182,16 @@ const checkExtension = (
}

for (const extension of extensions) {
if (path.endsWith(formatExtension(extension))) {
const formattedExtension = formatExtension(extension);
if (path.endsWith(formattedExtension)) {
if (ignoredExtensions) {
for (const ignoredExtension of ignoredExtensions) {
const formattedIgnoredExtension = formatExtension(ignoredExtension);
if (path.endsWith(formattedIgnoredExtension + formattedExtension)) {
return false;
}
}
}
return true;
}
}
18 changes: 18 additions & 0 deletions packages/load-files/tests/file-scanner.spec.ts
Original file line number Diff line number Diff line change
@@ -235,6 +235,24 @@ describe('file scanner', function() {
expect(typeof loadedFiles[0][customQueryTypeName]['foo']).toBe('function');
expect(loadedFiles[0][customQueryTypeName]['foo']()).toBe('FOO');
});
it(`${type}: ignore .d.ts files by default without file glob`, async () => {
const loadedFiles = await loadFiles(join(__dirname, './test-assets/ignore-extensions'));
expect(loadedFiles).toHaveLength(1);
const resolvers = loadedFiles[0];
expect(typeof resolvers).toBe('object');
expect(typeof resolvers.Query).toBe('object');
expect(typeof resolvers.Query.foo).toBe('function');
expect(resolvers.Query.foo()).toBe('FOO');
});
it(`${type}: ignore .d.ts files by default without file glob`, async () => {
const loadedFiles = await loadFiles(join(__dirname, './test-assets/ignore-extensions/*.*'));
expect(loadedFiles).toHaveLength(1);
const resolvers = loadedFiles[0];
expect(typeof resolvers).toBe('object');
expect(typeof resolvers.Query).toBe('object');
expect(typeof resolvers.Query.foo).toBe('function');
expect(resolvers.Query.foo()).toBe('FOO');
});
})
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export declare const resolvers: {
Query: {
foo: () => string;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports.resolvers = {
Query: {
foo: () => 'FOO'
}
}
2 changes: 1 addition & 1 deletion packages/relay-operation-optimizer/package.json
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
},
"dependencies": {
"@graphql-tools/utils": "^7.1.0",
"relay-compiler": "10.1.3",
"relay-compiler": "11.0.0",
"tslib": "~2.1.0"
},
"devDependencies": {
6 changes: 6 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @graphql-tools/utils

## 7.5.2

### Patch Changes

- de16fff4: Fix pruneSchema with unimplemented interfaces

## 7.5.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": "7.5.1",
"version": "7.5.2",
"description": "Common package containing utils and types for GraphQL tools",
"repository": {
"type": "git",
26 changes: 20 additions & 6 deletions packages/utils/src/prune.ts
Original file line number Diff line number Diff line change
@@ -49,7 +49,8 @@ export function pruneSchema(schema: GraphQLSchema, options: PruneSchemaOptions =
const type = schema.getType(typeName);
if ('getInterfaces' in type) {
type.getInterfaces().forEach(iface => {
if (pruningContext.implementations[iface.name] == null) {
const implementations = getImplementations(pruningContext, iface);
if (implementations == null) {
pruningContext.implementations[iface.name] = Object.create(null);
}
pruningContext.implementations[iface.name][type.name] = true;
@@ -76,11 +77,11 @@ export function pruneSchema(schema: GraphQLSchema, options: PruneSchemaOptions =
return null;
}
} else if (isInterfaceType(type)) {
const implementations = pruningContext.implementations[type.name] || {};
const implementations = getImplementations(pruningContext, type);

if (
(!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
(!Object.keys(implementations).length && !options.skipUnimplementedInterfacesPruning) ||
(implementations && !Object.keys(implementations).length && !options.skipUnimplementedInterfacesPruning) ||
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)
) {
return null;
@@ -121,9 +122,12 @@ function visitOutputType(
});

if (isInterfaceType(type)) {
Object.keys(pruningContext.implementations[type.name]).forEach(typeName => {
visitOutputType(visitedTypes, pruningContext, pruningContext.schema.getType(typeName) as NamedOutputType);
});
const implementations = getImplementations(pruningContext, type);
if (implementations) {
Object.keys(implementations).forEach(typeName => {
visitOutputType(visitedTypes, pruningContext, pruningContext.schema.getType(typeName) as NamedOutputType);
});
}
}

if ('getInterfaces' in type) {
@@ -137,6 +141,16 @@ function visitOutputType(
}
}

/**
* Get the implementations of an interface. May return undefined.
*/
function getImplementations(
pruningContext: PruningContext,
type: GraphQLNamedType
): Record<string, boolean> | undefined {
return pruningContext.implementations[type.name];
}

function visitInputType(
visitedTypes: Record<string, boolean>,
pruningContext: PruningContext,
16 changes: 15 additions & 1 deletion packages/utils/tests/prune.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildSchema } from 'graphql';
import { pruneSchema } from '../src/prune';

describe('prune', () => {
describe('pruneSchema', () => {
test('can handle recursive input types', () => {
const schema = buildSchema(`
input Input {
@@ -130,4 +130,18 @@ describe('prune', () => {
expect(result.getType('UnusedType')).toBeUndefined();
expect(result.getType('UnusedUnion')).toBeUndefined();
});

test('does not throw on pruning unimplemented interfaces', () => {
const schema = buildSchema(`
interface UnimplementedInterface {
value: String
}
type Query {
foo: UnimplementedInterface
}
`);
const result = pruneSchema(schema);
expect(result.getType('UnimplementedInterface')).toBeDefined();
});
});
28 changes: 0 additions & 28 deletions packages/utils/tests/pruneSchema.test.ts

This file was deleted.

26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -3977,10 +3977,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.9.tgz#04afc9a25c6ff93da14deabd65dc44485b53c8d6"
integrity sha512-JsoLXFppG62tWTklIoO4knA+oDTYsmqWxHRvd4lpmfQRNhX6osheUOWETP2jMoV/2bEHuMra8Pp3Dmo/stBFcw==

"@types/node@14.14.32":
version "14.14.32"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.32.tgz#90c5c4a8d72bbbfe53033f122341343249183448"
integrity sha512-/Ctrftx/zp4m8JOujM5ZhwzlWLx22nbQJiVqz8/zE15gOeEW+uly3FSX4fGFpcfEvFzXcMCJwq9lGVWgyARXhg==
"@types/node@14.14.33":
version "14.14.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.33.tgz#9e4f8c64345522e4e8ce77b334a8aaa64e2b6c78"
integrity sha512-oJqcTrgPUF29oUP8AsUqbXGJNuPutsetaa9kTQAQce5Lx5dTYWV02ScBiT/k1BX/Z7pKeqedmvp39Wu4zR7N7g==

"@types/node@^12.7.1":
version "12.12.62"
@@ -13787,10 +13787,10 @@ relateurl@^0.2.7:
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=

relay-compiler@10.1.3:
version "10.1.3"
resolved "https://registry.yarnpkg.com/relay-compiler/-/relay-compiler-10.1.3.tgz#76ec4fd5d16f5b6aae61183f64b5caaef27f2525"
integrity sha512-AJoET3U8PrLXiA1/jmcr5beR/928+8c8qf46nOuumaNXhTfJC2RvN2fpD0APF0Fti+oKBxwKcQJ93R5BK6A2xw==
relay-compiler@11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/relay-compiler/-/relay-compiler-11.0.0.tgz#265bded552b0938ad597ea14b9488e3d818b99cf"
integrity sha512-xAVcnWBNtkIJqRwae2agY+riDhh00bV/HqwbcBYijK/S9jKPEFLx9FguGG1V8EWgS/barBsBMtE7CG916GtSrA==
dependencies:
"@babel/core" "^7.0.0"
"@babel/generator" "^7.5.0"
@@ -13805,14 +13805,14 @@ relay-compiler@10.1.3:
glob "^7.1.1"
immutable "~3.7.6"
nullthrows "^1.1.1"
relay-runtime "10.1.3"
relay-runtime "11.0.0"
signedsource "^1.0.0"
yargs "^15.3.1"

relay-runtime@10.1.3:
version "10.1.3"
resolved "https://registry.yarnpkg.com/relay-runtime/-/relay-runtime-10.1.3.tgz#1d7bfe590b50cd7f18f6d1c0f20df71fe5bb451a"
integrity sha512-NSh4CaRRpUaziK72h4T5uKw6rvHovmS/xD9+czqUYg6yKv22ajwBE6SWmjwTSKnt2NBzIfDjh2C3heo9pLbvtg==
relay-runtime@11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/relay-runtime/-/relay-runtime-11.0.0.tgz#cb3244dc4e2919a51fdcbedddd5d13a20cf393e8"
integrity sha512-7oeyW4hulyK3p4eB63Rsllo/es83xflCAt2HMWCpH2q0fi21iJBR02kK3wCPM/yFwi3i0K83W+UksLFQdE0CaQ==
dependencies:
"@babel/runtime" "^7.0.0"
fbjs "^3.0.0"