From 6ba748bc3b1a648062a8e24493aa6fe8aedbfbd5 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sat, 29 Jun 2019 13:45:29 +0300 Subject: [PATCH] buildClientSchema: add test for missing standard scalar Context: https://github.com/graphql/graphql-js/issues/2005 --- .../__tests__/buildClientSchema-test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utilities/__tests__/buildClientSchema-test.js b/src/utilities/__tests__/buildClientSchema-test.js index a931534a8e..8b5e835292 100644 --- a/src/utilities/__tests__/buildClientSchema-test.js +++ b/src/utilities/__tests__/buildClientSchema-test.js @@ -581,6 +581,24 @@ describe('Type System: build schema from introspection', () => { ); }); + it('throws when missing definition for one of the standard scalars', () => { + const schema = buildSchema(` + type Query { + foo: Float + } + `); + const introspection = introspectionFromSchema(schema); + + // $DisableFlowOnNegativeTest + introspection.__schema.types = introspection.__schema.types.filter( + ({ name }) => name !== 'Float', + ); + + expect(() => buildClientSchema(introspection)).to.throw( + 'Invalid or incomplete schema, unknown type: Float. Ensure that a full introspection query is used in order to build a client schema.', + ); + }); + it('throws when type reference is missing name', () => { const introspection = introspectionFromSchema(dummySchema);