diff --git a/src/decorators/Fields.ts b/src/decorators/Fields.ts index 1ae0e829..3b28f43a 100644 --- a/src/decorators/Fields.ts +++ b/src/decorators/Fields.ts @@ -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; diff --git a/src/test/functional/__snapshots__/server.test.ts.snap b/src/test/functional/__snapshots__/server.test.ts.snap index 798f9c5a..c3936218 100644 --- a/src/test/functional/__snapshots__/server.test.ts.snap +++ b/src/test/functional/__snapshots__/server.test.ts.snap @@ -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 { diff --git a/src/test/functional/server.test.ts b/src/test/functional/server.test.ts index b2d0928a..e8785da2 100644 --- a/src/test/functional/server.test.ts +++ b/src/test/functional/server.test.ts @@ -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);