Skip to content

Commit

Permalink
Remove unnecessary async code, part 2
Browse files Browse the repository at this point in the history
Continuation of graphql#269
  • Loading branch information
IvanGoncharov committed Jun 25, 2020
1 parent 5b42850 commit 913e250
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/node/__tests__/plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
graphql,
graphqlSync,
} from 'graphql';

import { pluralIdentifyingRootField } from '../plural';
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('pluralIdentifyingRootField()', () => {
}
`;

expect(await graphql(schema, query, null, context)).to.deep.equal({
expect(graphqlSync(schema, query, null, context)).to.deep.equal({
data: {
usernames: [
{
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('pluralIdentifyingRootField()', () => {
}
`;

expect(await graphql(schema, query)).to.deep.equal({
expect(graphqlSync(schema, query)).to.deep.equal({
data: {
__schema: {
queryType: {
Expand Down
16 changes: 6 additions & 10 deletions src/node/plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,21 @@ type PluralIdentifyingRootFieldConfig = {|
export function pluralIdentifyingRootField(
config: PluralIdentifyingRootFieldConfig,
): GraphQLFieldConfig<mixed, mixed> {
const inputArgs = {};
let inputType = config.inputType;
if (isNonNullType(inputType)) {
inputType = inputType.ofType;
}
inputArgs[config.argName] = {
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(inputType))),
};
return {
description: config.description,
type: new GraphQLList(config.outputType),
args: inputArgs,
args: {
[config.argName]: {
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(inputType))),
},
},
resolve(_obj, args, context, info) {
const inputs = args[config.argName];
return Promise.all(
inputs.map((input) =>
Promise.resolve(config.resolveSingleInput(input, context, info)),
),
);
return inputs.map((input) => config.resolveSingleInput(input, context, info)),
},
};
}

0 comments on commit 913e250

Please sign in to comment.