Skip to content

Commit

Permalink
Merge pull request #355 from goldcaddy77/issue-354-typename
Browse files Browse the repository at this point in the history
fix(__typename): allow asking for __typename
  • Loading branch information
goldcaddy77 authored Apr 26, 2020
2 parents 601d5e2 + 9cab9d0 commit cc81747
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/decorators/Fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function Fields(): ParameterDecorator {
const rawFields = graphqlFields(info);

const scalars = Object.keys(rawFields).filter(item => {
return Object.keys(rawFields[item]).length === 0;
return Object.keys(rawFields[item]).length === 0 && !item.startsWith('__');
});

return scalars;
Expand Down
8 changes: 8 additions & 0 deletions src/test/functional/__snapshots__/server.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Array [
]
`;

exports[`server find: allows client to ask for __typename 1`] = `
Array [
Object {
"__typename": "KitchenSink",
},
]
`;

exports[`server find: enum field = BAR 1`] = `
Array [
Object {
Expand Down
8 changes: 8 additions & 0 deletions src/test/functional/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ describe('server', () => {
done();
});

test('find: allows client to ask for __typename', async () => {
expect.assertions(2);

const result = await binding.query.kitchenSinks({ limit: 1 }, '{ __typename }');
expect(result.length).toEqual(1);
expect(result).toMatchSnapshot();
});

test('find: string query: exact match (Nakia)', async () => {
expect.assertions(2);

Expand Down

0 comments on commit cc81747

Please sign in to comment.