Skip to content

Commit

Permalink
fix(__typename): allow asking for __typename
Browse files Browse the repository at this point in the history
  • Loading branch information
goldcaddy77 committed Apr 26, 2020
1 parent 601d5e2 commit 9cab9d0
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 9cab9d0

Please sign in to comment.