Skip to content

Commit

Permalink
Remove unnecessary async code, part 2 (#271)
Browse files Browse the repository at this point in the history
Continuation of #269
  • Loading branch information
IvanGoncharov committed Jun 25, 2020
1 parent 5b42850 commit bae5ead
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 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 @@ -47,7 +47,7 @@ const schema = new GraphQLSchema({
const context = { lang: 'en' };

describe('pluralIdentifyingRootField()', () => {
it('allows fetching', async () => {
it('allows fetching', () => {
const query = `
{
usernames(usernames:[ "dschafer", "leebyron", "schrockn" ]) {
Expand All @@ -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 All @@ -77,7 +77,7 @@ describe('pluralIdentifyingRootField()', () => {
});
});

it('correctly introspects', async () => {
it('correctly introspects', () => {
const query = `
{
__schema {
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
18 changes: 9 additions & 9 deletions src/node/plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ 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),
);
},
};
Expand Down

0 comments on commit bae5ead

Please sign in to comment.