Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
chore(deps): upgrade deps
Browse files Browse the repository at this point in the history
and run prettier
  • Loading branch information
yaacovCR committed Mar 23, 2020
1 parent 550b826 commit 3a2b7bd
Show file tree
Hide file tree
Showing 72 changed files with 426 additions and 420 deletions.
26 changes: 13 additions & 13 deletions package.json
Expand Up @@ -58,46 +58,46 @@
"form-data": "^3.0.0",
"iterall": "^1.3.0",
"node-fetch": "^2.6.0",
"uuid": "^7.0.1"
"uuid": "^7.0.2"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-rc"
},
"devDependencies": {
"@types/chai": "^4.2.9",
"@types/chai": "^4.2.11",
"@types/dateformat": "^3.0.1",
"@types/express": "^4.17.2",
"@types/express": "^4.17.3",
"@types/extract-files": "^3.1.0",
"@types/graphql-type-json": "^0.3.2",
"@types/graphql-upload": "^8.0.3",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.6",
"@types/mocha": "^7.0.2",
"@types/node": "^13.9.3",
"@types/node-fetch": "^2.5.5",
"@types/uuid": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"@types/uuid": "^7.0.2",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.25.0",
"babel-eslint": "^10.1.0",
"body-parser": "^1.19.0",
"chai": "^4.2.0",
"coveralls": "^3.0.9",
"coveralls": "^3.0.11",
"dataloader": "^2.0.0",
"dateformat": "^3.0.3",
"eslint": "^6.8.0",
"eslint-plugin-import": "2.20.0",
"eslint-plugin-import": "2.20.1",
"eslint-watch": "^6.0.1",
"express": "^4.17.1",
"express-graphql": "^0.9.0",
"graphql": "^14.6.0",
"graphql-subscriptions": "^1.1.0",
"graphql-type-json": "^0.3.1",
"graphql-upload": "^10.0.0",
"mocha": "^7.1.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.2",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.16",
"standard-version": "^7.1.0",
"typescript": "^3.8.2",
"typescript": "^3.8.3",
"zen-observable-ts": "^0.8.20"
}
}
18 changes: 9 additions & 9 deletions src/delegate/checkResultAndHandleErrors.ts
Expand Up @@ -177,7 +177,7 @@ export function handleObject(
) {
setErrors(
object,
errors.map(error =>
errors.map((error) =>
relocatedError(
error,
error.nodes,
Expand Down Expand Up @@ -206,7 +206,7 @@ export function handleObject(
return object;
}

targetSubschemas = targetSubschemas.filter(s => s !== subschema);
targetSubschemas = targetSubschemas.filter((s) => s !== subschema);
if (!targetSubschemas.length) {
return object;
}
Expand Down Expand Up @@ -235,7 +235,7 @@ export function handleObject(
function collectSubFields(info: IGraphQLToolsResolveInfo, typeName: string) {
let subFieldNodes: Record<string, Array<FieldNode>> = Object.create(null);
const visitedFragmentNames = Object.create(null);
info.fieldNodes.forEach(fieldNode => {
info.fieldNodes.forEach((fieldNode) => {
subFieldNodes = collectFields(
({
schema: info.schema,
Expand Down Expand Up @@ -263,8 +263,8 @@ function getFieldsNotInSubschema(
const fields = (typeMap[typeName] as GraphQLObjectType).getFields();

const fieldsNotInSchema: Array<FieldNode> = [];
Object.keys(subFieldNodes).forEach(responseName => {
subFieldNodes[responseName].forEach(subFieldNode => {
Object.keys(subFieldNodes).forEach((responseName) => {
subFieldNodes[responseName].forEach((subFieldNode) => {
if (!fields[subFieldNode.name.value]) {
fieldsNotInSchema.push(subFieldNode);
}
Expand All @@ -280,13 +280,13 @@ export function handleNull(
errors: ReadonlyArray<GraphQLError>,
) {
if (errors.length) {
if (errors.some(error => !error.path || error.path.length < 2)) {
if (errors.some((error) => !error.path || error.path.length < 2)) {
return relocatedError(combineErrors(errors), fieldNodes, path);
} else if (errors.some(error => typeof error.path[1] === 'string')) {
} else if (errors.some((error) => typeof error.path[1] === 'string')) {
const childErrors = getErrorsByPathSegment(errors);

const result = Object.create(null);
Object.keys(childErrors).forEach(pathSegment => {
Object.keys(childErrors).forEach((pathSegment) => {
result[pathSegment] = handleNull(
fieldNodes,
[...path, pathSegment],
Expand All @@ -300,7 +300,7 @@ export function handleNull(
const childErrors = getErrorsByPathSegment(errors);

const result: Array<any> = [];
Object.keys(childErrors).forEach(pathSegment => {
Object.keys(childErrors).forEach((pathSegment) => {
result.push(
handleNull(
fieldNodes,
Expand Down
4 changes: 2 additions & 2 deletions src/delegate/createRequest.ts
Expand Up @@ -160,7 +160,7 @@ export function createRequest(

const fragmentDefinitions: Array<FragmentDefinitionNode> = Object.keys(
fragments,
).map(fragmentName => fragments[fragmentName]);
).map((fragmentName) => fragments[fragmentName]);

const document = {
kind: Kind.DOCUMENT,
Expand Down Expand Up @@ -254,7 +254,7 @@ function updateArguments(
});

return {
arguments: Object.keys(updatedArgs).map(argName => updatedArgs[argName]),
arguments: Object.keys(updatedArgs).map((argName) => updatedArgs[argName]),
variableDefinitions: newVariableDefinitions,
variableValues,
};
Expand Down
2 changes: 1 addition & 1 deletion src/delegate/delegateToSchema.ts
Expand Up @@ -235,7 +235,7 @@ export function delegateRequest({
// "subscribe" to the subscription result and map the result through the transforms
return mapAsyncIterator<ExecutionResult, any>(
subscriptionResult,
result => {
(result) => {
const transformedResult = applyResultTransforms(
result,
delegationTransforms,
Expand Down
20 changes: 11 additions & 9 deletions src/generate/addResolversToSchema.ts
Expand Up @@ -60,13 +60,15 @@ function addResolversToSchema(

const typeMap = schema.getTypeMap();

Object.keys(resolvers).forEach(typeName => {
Object.keys(resolvers).forEach((typeName) => {
const resolverValue = resolvers[typeName];
const resolverType = typeof resolverValue;

if (resolverType !== 'object' && resolverType !== 'function') {
throw new SchemaError(
`"${typeName}" defined in resolvers, but has invalid value "${resolverValue as string}". A resolver's value must be of type object or function.`,
`"${typeName}" defined in resolvers, but has invalid value "${
resolverValue as string
}". A resolver's value must be of type object or function.`,
);
}

Expand All @@ -84,7 +86,7 @@ function addResolversToSchema(

if (isScalarType(type)) {
// Support -- without recommending -- overriding default scalar types
Object.keys(resolverValue).forEach(fieldName => {
Object.keys(resolverValue).forEach((fieldName) => {
if (fieldName.startsWith('__')) {
type[fieldName.substring(2)] = resolverValue[fieldName];
} else {
Expand All @@ -95,7 +97,7 @@ function addResolversToSchema(
// We've encountered an enum resolver that is being used to provide an
// internal enum value.
// Reference: https://www.apollographql.com/docs/graphql-tools/scalars.html#internal-values
Object.keys(resolverValue).forEach(fieldName => {
Object.keys(resolverValue).forEach((fieldName) => {
if (!type.getValue(fieldName)) {
if (allowResolversNotInSchema) {
return;
Expand All @@ -110,7 +112,7 @@ function addResolversToSchema(

const values = type.getValues();
const newValues = {};
values.forEach(value => {
values.forEach((value) => {
const newValue = Object.keys(resolverValue).includes(value.name)
? resolverValue[value.name]
: value.name;
Expand All @@ -128,7 +130,7 @@ function addResolversToSchema(
values: newValues,
});
} else if (isUnionType(type)) {
Object.keys(resolverValue).forEach(fieldName => {
Object.keys(resolverValue).forEach((fieldName) => {
if (fieldName.startsWith('__')) {
// this is for isTypeOf and resolveType and all the other stuff.
type[fieldName.substring(2)] = resolverValue[fieldName];
Expand All @@ -143,7 +145,7 @@ function addResolversToSchema(
);
});
} else if (isObjectType(type) || isInterfaceType(type)) {
Object.keys(resolverValue).forEach(fieldName => {
Object.keys(resolverValue).forEach((fieldName) => {
if (fieldName.startsWith('__')) {
// this is for isTypeOf and resolveType and all the other stuff.
type[fieldName.substring(2)] = resolverValue[fieldName];
Expand Down Expand Up @@ -189,7 +191,7 @@ function addResolversToSchema(
forEachDefaultValue(schema, parseInputValue);

if (defaultFieldResolver != null) {
forEachField(schema, field => {
forEachField(schema, (field) => {
if (!field.resolve) {
field.resolve = defaultFieldResolver;
}
Expand All @@ -203,7 +205,7 @@ function setFieldProperties(
field: GraphQLField<any, any>,
propertiesObj: Record<string, any>,
) {
Object.keys(propertiesObj).forEach(propertyName => {
Object.keys(propertiesObj).forEach((propertyName) => {
field[propertyName] = propertiesObj[propertyName];
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/generate/addSchemaLevelResolver.ts
Expand Up @@ -15,14 +15,14 @@ function addSchemaLevelResolver(
schema.getQueryType(),
schema.getMutationType(),
schema.getSubscriptionType(),
].filter(x => Boolean(x));
rootTypes.forEach(type => {
].filter((x) => Boolean(x));
rootTypes.forEach((type) => {
if (type != null) {
// XXX this should run at most once per request to simulate a true root resolver
// for graphql-js this is an approximation that works with queries but not mutations
const rootResolveFn = runAtMostOncePerRequest(fn);
const fields = type.getFields();
Object.keys(fields).forEach(fieldName => {
Object.keys(fields).forEach((fieldName) => {
// XXX if the type is a subscription, a same query AST will be ran multiple times so we
// deactivate here the runOnce if it's a subscription. This may not be optimal though...
if (type === schema.getSubscriptionType()) {
Expand All @@ -47,7 +47,7 @@ function wrapResolver(
outerResolver: GraphQLFieldResolver<any, any>,
): GraphQLFieldResolver<any, any> {
return (obj, args, ctx, info) =>
Promise.resolve(outerResolver(obj, args, ctx, info)).then(root => {
Promise.resolve(outerResolver(obj, args, ctx, info)).then((root) => {
if (innerResolver != null) {
return innerResolver(root, args, ctx, info);
}
Expand Down
2 changes: 1 addition & 1 deletion src/generate/attachConnectorsToContext.ts
Expand Up @@ -56,7 +56,7 @@ const attachConnectorsToContext = deprecated<Function>(
if (typeof ctx.connectors === 'undefined') {
ctx.connectors = {};
}
Object.keys(connectors).forEach(connectorName => {
Object.keys(connectors).forEach((connectorName) => {
const connector: IConnector = connectors[connectorName];
if (connector.prototype != null) {
ctx.connectors[connectorName] = new (connector as IConnectorCls)(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/generate/attachDirectiveResolvers.ts
Expand Up @@ -21,7 +21,7 @@ function attachDirectiveResolvers(

const schemaDirectives = Object.create(null);

Object.keys(directiveResolvers).forEach(directiveName => {
Object.keys(directiveResolvers).forEach((directiveName) => {
schemaDirectives[directiveName] = class extends SchemaDirectiveVisitor {
public visitFieldDefinition(field: GraphQLField<any, any>) {
const resolver = directiveResolvers[directiveName];
Expand Down
2 changes: 1 addition & 1 deletion src/generate/checkForResolveTypeResolver.ts
Expand Up @@ -13,7 +13,7 @@ function checkForResolveTypeResolver(
requireResolversForResolveType?: boolean,
) {
Object.keys(schema.getTypeMap())
.map(typeName => schema.getType(typeName))
.map((typeName) => schema.getType(typeName))
.forEach((type: GraphQLUnionType | GraphQLInterfaceType) => {
if (!isAbstractType(type)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/generate/concatenateTypeDefs.ts
Expand Up @@ -28,7 +28,7 @@ function concatenateTypeDefs(
);
}
});
return uniq(resolvedTypeDefinitions.map(x => x.trim())).join('\n');
return uniq(resolvedTypeDefinitions.map((x) => x.trim())).join('\n');
}

function uniq(array: Array<any>): Array<any> {
Expand Down
4 changes: 2 additions & 2 deletions src/generate/extendResolversFromInterfaces.ts
Expand Up @@ -18,7 +18,7 @@ function extendResolversFromInterfaces(
});

const extendedResolvers: IResolvers = {};
typeNames.forEach(typeName => {
typeNames.forEach((typeName) => {
const typeResolvers = resolvers[typeName];
const type = schema.getType(typeName);
if (
Expand All @@ -27,7 +27,7 @@ function extendResolversFromInterfaces(
) {
const interfaceResolvers = (type as GraphQLObjectType)
.getInterfaces()
.map(iFace => resolvers[iFace.name]);
.map((iFace) => resolvers[iFace.name]);
extendedResolvers[typeName] = Object.assign(
{},
...interfaceResolvers,
Expand Down
2 changes: 1 addition & 1 deletion src/generate/makeExecutableSchema.ts
Expand Up @@ -46,7 +46,7 @@ export function makeExecutableSchema<TContext = any>({
// We allow passing in an array of resolver maps, in which case we merge them
const resolverMap = Array.isArray(resolvers)
? resolvers
.filter(resolverObj => typeof resolverObj === 'object')
.filter((resolverObj) => typeof resolverObj === 'object')
.reduce(mergeDeep, {})
: resolvers;

Expand Down
22 changes: 11 additions & 11 deletions src/links/createServerHttpLink.ts
Expand Up @@ -116,7 +116,7 @@ export const createServerHttpLink = (linkOptions: Options = {}) => {
headers: requestOptions.headers,
};

return new ApolloLink(operation => {
return new ApolloLink((operation) => {
let chosenURI = selectURI(operation, uri);

const context = operation.getContext();
Expand Down Expand Up @@ -183,9 +183,9 @@ export const createServerHttpLink = (linkOptions: Options = {}) => {
chosenURI = newURI;
}

return new Observable(observer => {
return new Observable((observer) => {
getFinalPromise(body)
.then(resolvedBody => {
.then((resolvedBody) => {
if (options.method !== 'GET') {
options.body = customSerializer(resolvedBody, customAppendFile);
if (options.body instanceof FormData) {
Expand All @@ -195,19 +195,19 @@ export const createServerHttpLink = (linkOptions: Options = {}) => {
}
return options;
})
.then(newOptions => customFetch(chosenURI, newOptions))
.then(response => {
.then((newOptions) => customFetch(chosenURI, newOptions))
.then((response) => {
operation.setContext({ response });
return response;
})
.then(parseAndCheckHttpResponse(operation))
.then(result => {
.then((result) => {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
return result;
})
.catch(err => {
.catch((err) => {
// fetch was cancelled so it's already been cleaned up in the unsubscribe
if (err.name === 'AbortError') {
return;
Expand Down Expand Up @@ -322,18 +322,18 @@ function rewriteURIForGET(chosenURI: string, body: Body) {
}

function getFinalPromise(object: any): Promise<any> {
return Promise.resolve(object).then(resolvedObject => {
return Promise.resolve(object).then((resolvedObject) => {
if (resolvedObject == null) {
return resolvedObject;
}

if (Array.isArray(resolvedObject)) {
return Promise.all(resolvedObject.map(o => getFinalPromise(o)));
return Promise.all(resolvedObject.map((o) => getFinalPromise(o)));
} else if (typeof resolvedObject === 'object') {
const keys = Object.keys(resolvedObject);
return Promise.all(
keys.map(key => getFinalPromise(resolvedObject[key])),
).then(awaitedValues => {
keys.map((key) => getFinalPromise(resolvedObject[key])),
).then((awaitedValues) => {
for (let i = 0; i < keys.length; i++) {
resolvedObject[keys[i]] = awaitedValues[i];
}
Expand Down

0 comments on commit 3a2b7bd

Please sign in to comment.