Skip to content

Commit

Permalink
Huge cleanup before major release (breaking) (#3081)
Browse files Browse the repository at this point in the history
* Breaking cleanup before major release

* Fix TS

* More
  • Loading branch information
ardatan authored Jun 21, 2021
1 parent 806faae commit e01d6b9
Show file tree
Hide file tree
Showing 84 changed files with 389 additions and 5,596 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-horses-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': major
---

BREAKING - Remove fieldToFieldConfig, fieldToFieldConfig, argsToFieldConfigArgument and argumentToArgumentConfig
7 changes: 7 additions & 0 deletions .changeset/forty-ducks-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-tools/schema': major
'@graphql-tools/stitch': major
'@graphql-tools/utils': major
---

BREAKING - deprecate legacy schema directives and directive resolvers
5 changes: 5 additions & 0 deletions .changeset/heavy-vans-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/schema': major
---

breaking - remove logger and addErrorLoggingToSchema - use envelop instead
5 changes: 5 additions & 0 deletions .changeset/long-rings-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'graphql-tools': major
---

Add deprecation notice and export makeExecutableSchema only
8 changes: 8 additions & 0 deletions .changeset/mean-news-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-tools/delegate': major
'@graphql-tools/apollo-engine-loader': major
'@graphql-tools/utils': major
'@graphql-tools/wrap': major
---

BREAKING - Use native AggregateError if possible. Native AggregateError doesn't have iterator but errors prop
5 changes: 5 additions & 0 deletions .changeset/new-balloons-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/schema': major
---

BREAKING - enhance(schema): remove schema level resolvers and addSchemaLevelResolver
5 changes: 5 additions & 0 deletions .changeset/ninety-shirts-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': major
---

BREAKING - remove debugLog
5 changes: 5 additions & 0 deletions .changeset/polite-yaks-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': major
---

BREAKING - do not apply camelCase naming convention in buildOperationNodeForField
5 changes: 5 additions & 0 deletions .changeset/silent-comics-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/schema': major
---

BREAKING(schema) - remove allowUndefinedResolve option, buildSchemaFromTypeDefinitions and use buildSchema instead
5 changes: 5 additions & 0 deletions .changeset/smooth-tips-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': major
---

BREAKING - Remove SchemaVisitor, visitSchema and VisitSchemaKind
5 changes: 5 additions & 0 deletions .changeset/twelve-suns-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/schema': patch
---

enhance(schema): use merge package to handle typeDefs and resolvers merging
7 changes: 3 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ jobs:
- name: Build
run: yarn ts:transpile
test:
name: Test on ${{matrix.os}}, Node ${{matrix.node_version}} and GraphQL v${{matrix.graphql_version}}
runs-on: ${{matrix.os}}
name: Test, Node ${{matrix.node_version}} and GraphQL v${{matrix.graphql_version}}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest] # remove windows to speed up the tests
node_version: [10, 16]
node_version: [12, 16]
graphql_version: [14, 15]
steps:
- name: Checkout Master
Expand Down
1 change: 0 additions & 1 deletion packages/delegate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@graphql-tools/batch-execute": "^7.1.2",
"@graphql-tools/schema": "^7.1.5",
"@graphql-tools/utils": "^7.7.1",
"@ardatan/aggregate-error": "0.0.6",
"dataloader": "2.0.0",
"tslib": "~2.3.0",
"value-or-promise": "1.0.10"
Expand Down
3 changes: 1 addition & 2 deletions packages/delegate/src/delegateToSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {

import { ValueOrPromise } from 'value-or-promise';

import AggregateError from '@ardatan/aggregate-error';

import { getBatchingExecutor } from '@graphql-tools/batch-execute';

import {
Expand All @@ -26,6 +24,7 @@ import {
Subscriber,
Maybe,
assertSome,
AggregateError,
} from '@graphql-tools/utils';

import {
Expand Down
3 changes: 1 addition & 2 deletions packages/delegate/src/resolveExternalValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import {
locatedError,
} from 'graphql';

import AggregateError from '@ardatan/aggregate-error';
import { AggregateError, Maybe } from '@graphql-tools/utils';

import { StitchingInfo, SubschemaConfig } from './types';
import { annotateExternalObject, isExternalObject } from './externalObjects';
import { getFieldsNotInSubschema } from './getFieldsNotInSubschema';
import { mergeFields } from './mergeFields';
import { Subschema } from './Subschema';
import { Maybe } from '@graphql-tools/utils';

export function resolveExternalValue(
result: any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {
locatedError,
} from 'graphql';

import AggregateError from '@ardatan/aggregate-error';

import { getResponseKeyFromInfo, ExecutionResult, relocatedError } from '@graphql-tools/utils';
import { AggregateError, getResponseKeyFromInfo, ExecutionResult, relocatedError } from '@graphql-tools/utils';

import { SubschemaConfig, Transform, DelegationContext } from '../types';
import { resolveExternalValue } from '../resolveExternalValue';
Expand Down
23 changes: 0 additions & 23 deletions packages/graphql-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,7 @@
"directory": "dist"
},
"dependencies": {
"@graphql-tools/optimize": "1.0.1",
"@graphql-tools/batch-delegate": "^7.0.0",
"@graphql-tools/batch-execute": "^7.0.0",
"@graphql-tools/delegate": "^7.0.10",
"@graphql-tools/graphql-tag-pluck": "^6.2.6",
"@graphql-tools/import": "^6.2.4",
"@graphql-tools/links": "^7.0.4",
"@graphql-tools/load": "^6.2.5",
"@graphql-tools/code-file-loader": "^6.2.5",
"@graphql-tools/git-loader": "^6.2.5",
"@graphql-tools/github-loader": "^6.2.5",
"@graphql-tools/graphql-file-loader": "^6.2.5",
"@graphql-tools/json-file-loader": "^6.2.5",
"@graphql-tools/module-loader": "^6.2.5",
"@graphql-tools/url-loader": "^6.3.2",
"@graphql-tools/load-files": "^6.2.4",
"@graphql-tools/merge": "^6.2.14",
"@graphql-tools/mock": "^7.0.0",
"@graphql-tools/relay-operation-optimizer": "^6.2.5",
"@graphql-tools/resolvers-composition": "^6.2.5",
"@graphql-tools/schema": "^7.0.0",
"@graphql-tools/stitch": "^7.3.0",
"@graphql-tools/utils": "^7.0.1",
"@graphql-tools/wrap": "^7.0.0",
"tslib": "~2.3.0"
}
}
28 changes: 5 additions & 23 deletions packages/graphql-tools/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
export * from '@graphql-tools/batch-delegate';
export * from '@graphql-tools/batch-execute';
export * from '@graphql-tools/delegate';
export * from '@graphql-tools/graphql-tag-pluck';
export * from '@graphql-tools/import';
export * from '@graphql-tools/links';
export * from '@graphql-tools/load';
export * from '@graphql-tools/code-file-loader';
export * from '@graphql-tools/git-loader';
export * from '@graphql-tools/github-loader';
export * from '@graphql-tools/graphql-file-loader';
export * from '@graphql-tools/module-loader';
export * from '@graphql-tools/url-loader';
export * from '@graphql-tools/load-files';
export * from '@graphql-tools/merge';
export * from '@graphql-tools/mock';
export * from '@graphql-tools/relay-operation-optimizer';
export * from '@graphql-tools/resolvers-composition';
export * from '@graphql-tools/schema';
export * from '@graphql-tools/stitch';
export * from '@graphql-tools/utils';
export * from '@graphql-tools/wrap';
export * from '@graphql-tools/optimize';
export { makeExecutableSchema } from '@graphql-tools/schema';

console.warn(`This package has been deprecated and now it only exports makeExecutableSchema.
We recommend you to migrate to scoped packages.
Check out https://www.graphql-tools.com for more information!`);
6 changes: 4 additions & 2 deletions packages/load/src/filter-document-kind.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { debugLog } from '@graphql-tools/utils';
import { DocumentNode, DefinitionNode, Kind } from 'graphql';
import { env } from 'process';

/**
* @internal
Expand All @@ -18,7 +18,9 @@ export const filterKind = (content: DocumentNode | undefined, filterKinds: null

if (invalidDefinitions.length > 0) {
invalidDefinitions.forEach(d => {
debugLog(`Filtered document of kind ${d.kind} due to filter policy (${filterKinds.join(', ')})`);
if (env['DEBUG']) {
console.error(`Filtered document of kind ${d.kind} due to filter policy (${filterKinds.join(', ')})`);
}
});
}

Expand Down
11 changes: 8 additions & 3 deletions packages/load/src/load-typedefs/load-file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Source, debugLog, Maybe } from '@graphql-tools/utils';
import { Source, Maybe } from '@graphql-tools/utils';
import { env } from 'process';
import { LoadTypedefsOptions } from '../load-typedefs';

export async function loadFile(pointer: string, options: LoadTypedefsOptions): Promise<Maybe<Source>> {
Expand All @@ -17,7 +18,9 @@ export async function loadFile(pointer: string, options: LoadTypedefsOptions): P
return loadedValue;
}
} catch (error) {
debugLog(`Failed to find any GraphQL type definitions in: ${pointer} - ${error.message}`);
if (env['DEBUG']) {
console.error(`Failed to find any GraphQL type definitions in: ${pointer} - ${error.message}`);
}
throw error;
}
}
Expand All @@ -41,7 +44,9 @@ export function loadFileSync(pointer: string, options: LoadTypedefsOptions): May
return loader.loadSync!(pointer, options);
}
} catch (error) {
debugLog(`Failed to find any GraphQL type definitions in: ${pointer} - ${error.message}`);
if (env['DEBUG']) {
console.error(`Failed to find any GraphQL type definitions in: ${pointer} - ${error.message}`);
}
throw error;
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/loaders/apollo-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"graphql": "^14.0.0 || ^15.0.0"
},
"dependencies": {
"@ardatan/aggregate-error": "0.0.6",
"@graphql-tools/utils": "^7.0.0",
"@graphql-tools/utils": "^7.10.0",
"cross-fetch": "3.1.4",
"tslib": "~2.3.0",
"sync-fetch": "0.3.0"
Expand Down
7 changes: 3 additions & 4 deletions packages/loaders/apollo-engine/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SchemaLoader, Source, SingleFileOptions, parseGraphQLSDL } from '@graphql-tools/utils';
import { SchemaLoader, Source, SingleFileOptions, parseGraphQLSDL, AggregateError } from '@graphql-tools/utils';
import { fetch } from 'cross-fetch';
import AggregateError from '@ardatan/aggregate-error';
import syncFetch from 'sync-fetch';

/**
Expand Down Expand Up @@ -66,7 +65,7 @@ export class ApolloEngineLoader implements SchemaLoader<ApolloEngineOptions> {
const { data, errors } = await response.json();

if (errors) {
throw new AggregateError(errors);
throw new AggregateError(errors, 'Introspection from Apollo Engine failed');
}

return parseGraphQLSDL(pointer, data.service.schema.document, options);
Expand All @@ -79,7 +78,7 @@ export class ApolloEngineLoader implements SchemaLoader<ApolloEngineOptions> {
const { data, errors } = response.json();

if (errors) {
throw new AggregateError(errors);
throw new AggregateError(errors, 'Introspection from Apollo Engine failed');
}

return parseGraphQLSDL(pointer, data.service.schema.document, options);
Expand Down
11 changes: 7 additions & 4 deletions packages/loaders/code-file/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { isSchema, GraphQLSchema, DocumentNode } from 'graphql';
import {
SchemaPointerSingle,
DocumentPointerSingle,
debugLog,
SingleFileOptions,
Source,
UniversalLoader,
Expand All @@ -24,7 +23,7 @@ import isGlob from 'is-glob';
import unixify from 'unixify';
import { tryToLoadFromExport, tryToLoadFromExportSync } from './load-from-module';
import { isAbsolute, resolve } from 'path';
import { cwd } from 'process';
import { cwd, env } from 'process';
import { readFileSync, promises as fsPromises, existsSync } from 'fs';

const { readFile, access } = fsPromises;
Expand Down Expand Up @@ -135,7 +134,9 @@ export class CodeFileLoader implements UniversalLoader<CodeFileLoaderOptions> {
return parseGraphQLSDL(pointer, sdl, options);
}
} catch (e) {
debugLog(`Failed to load schema from code file "${normalizedFilePath}": ${e.message}`);
if (env['DEBUG']) {
console.error(`Failed to load schema from code file "${normalizedFilePath}": ${e.message}`);
}
errors.push(e);
}
}
Expand Down Expand Up @@ -178,7 +179,9 @@ export class CodeFileLoader implements UniversalLoader<CodeFileLoaderOptions> {
return parseGraphQLSDL(pointer, sdl, options);
}
} catch (e) {
debugLog(`Failed to load schema from code file "${normalizedFilePath}": ${e.message}`);
if (env['DEBUG']) {
console.error(`Failed to load schema from code file "${normalizedFilePath}": ${e.message}`);
}
errors.push(e);
}
}
Expand Down
18 changes: 9 additions & 9 deletions packages/loaders/prisma/src/prisma-yml/Variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as lodash from 'lodash';
import _ from 'lodash';
// eslint-disable-next-line
// @ts-ignore
import replaceall from 'replaceall';
Expand Down Expand Up @@ -43,18 +43,18 @@ export class Variables {
const deepMapValues = (object: any, callback: any, propertyPath?: string[]): any => {
const deepMapValuesIteratee = (value: any, key: any) =>
deepMapValues(value, callback, propertyPath ? propertyPath.concat(key) : [key]);
if (lodash.isArray(object)) {
return lodash.map(object, deepMapValuesIteratee);
} else if (lodash.isObject(object) && !lodash.isDate(object) && !lodash.isFunction(object)) {
return lodash.extend({}, object, lodash.mapValues(object, deepMapValuesIteratee));
if (_.isArray(object)) {
return _.map(object, deepMapValuesIteratee);
} else if (_.isObject(object) && !_.isDate(object) && !_.isFunction(object)) {
return _.extend({}, object, _.mapValues(object, deepMapValuesIteratee));
}
return callback(object, propertyPath);
};

deepMapValues(objectToPopulate, (property: any, propertyPath: any) => {
if (typeof property === 'string') {
const populateSingleProperty = this.populateProperty(property, true).then((newProperty: any) =>
lodash.set(objectToPopulate, propertyPath, newProperty)
_.set(objectToPopulate, propertyPath, newProperty)
);
populateAll.push(populateSingleProperty);
}
Expand All @@ -64,7 +64,7 @@ export class Variables {
}

populateProperty(propertyParam: any, populateInPlace?: boolean): any {
let property = populateInPlace ? propertyParam : lodash.cloneDeep(propertyParam);
let property = populateInPlace ? propertyParam : _.cloneDeep(propertyParam);
const allValuesToPopulate: any[] = [];
let warned = false;

Expand Down Expand Up @@ -143,7 +143,7 @@ export class Variables {
return (
finalValue !== null &&
typeof finalValue !== 'undefined' &&
!(typeof finalValue === 'object' && lodash.isEmpty(finalValue))
!(typeof finalValue === 'object' && _.isEmpty(finalValue))
);
});
return Promise.resolve(finalValue);
Expand Down Expand Up @@ -215,7 +215,7 @@ export class Variables {
if (
valueToPopulate === null ||
typeof valueToPopulate === 'undefined' ||
(typeof valueToPopulate === 'object' && lodash.isEmpty(valueToPopulate))
(typeof valueToPopulate === 'object' && _.isEmpty(valueToPopulate))
) {
let varType;
if (variableString.match(this.envRefSyntax)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/loaders/prisma/src/prisma-yml/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { invert } from 'lodash';
import _ from 'lodash';

export const cloudApiEndpoint = process.env['CLOUD_API_ENDPOINT'] || 'https://api.cloud.prisma.sh';

Expand All @@ -7,4 +7,4 @@ export const clusterEndpointMap: { [key: string]: string } = {
'prisma-us1': 'https://us1.prisma.sh',
};

export const clusterEndpointMapReverse: { [key: string]: string } = invert(clusterEndpointMap);
export const clusterEndpointMapReverse: { [key: string]: string } = _.invert(clusterEndpointMap);
Loading

0 comments on commit e01d6b9

Please sign in to comment.