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

Commit

Permalink
fix(stitching): fix regression
Browse files Browse the repository at this point in the history
Refactoring in v5.1.0 introduced a regression when nullable root fields returned
null without errors.
  • Loading branch information
yaacovCR committed Sep 22, 2019
1 parent 5c22fe8 commit 9005104
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/stitching/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export function checkResultAndHandleErrors(
info.fieldNodes,
responsePathAsArray(info.path)
);
} else {
return null;
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/test/testAlternateMergeSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from './testingSchemas';
import { forAwaitEach } from 'iterall';
import { createResolveType, fieldToFieldConfig } from '../stitching/schemaRecreation';
import { makeExecutableSchema } from '../makeExecutableSchema';

let linkSchema = `
"""
Expand Down Expand Up @@ -509,3 +510,30 @@ async () => {
});
});

describe('mergeSchemas', () => {
it('can merge null root fields', async () => {
const schema = makeExecutableSchema({
typeDefs: `
type Query {
test: Test
}
type Test {
field: String
}
`,
resolvers: {
Query: {
test: () => null
}
}
});
const mergedSchema = mergeSchemas({
schemas: [schema]
});

const query = `{ test { field } }`;
const response = await graphql(mergedSchema, query);
expect(response.data.test).to.be.null;
expect(response.errors).to.be.undefined;
});
});

0 comments on commit 9005104

Please sign in to comment.