diff --git a/src/__tests__/graphql-test.js b/src/__tests__/graphql-test.js deleted file mode 100644 index 764909dba2..0000000000 --- a/src/__tests__/graphql-test.js +++ /dev/null @@ -1,18 +0,0 @@ -// @flow strict - -import { expect } from 'chai'; -import { describe, it } from 'mocha'; - -import { GraphQLSchema } from '../type/schema'; - -import { graphqlSync } from '../graphql'; - -describe('graphql', () => { - it('report errors raised during schema validation', () => { - const schema = new GraphQLSchema({}); - const result = graphqlSync({ schema, source: '{ __typename }' }); - expect(result).to.deep.equal({ - errors: [{ message: 'Query root type must be provided.' }], - }); - }); -}); diff --git a/src/type/__tests__/validation-test.js b/src/type/__tests__/validation-test.js index b17245812f..ed733032f0 100644 --- a/src/type/__tests__/validation-test.js +++ b/src/type/__tests__/validation-test.js @@ -189,35 +189,6 @@ describe('Type System: A Schema must have Object root types', () => { expect(validateSchema(schemaWithDef)).to.deep.equal([]); }); - it('rejects a Schema without a query type', () => { - const schema = buildSchema(` - type Mutation { - test: String - } - `); - expect(validateSchema(schema)).to.deep.equal([ - { - message: 'Query root type must be provided.', - }, - ]); - - const schemaWithDef = buildSchema(` - schema { - mutation: MutationRoot - } - - type MutationRoot { - test: String - } - `); - expect(validateSchema(schemaWithDef)).to.deep.equal([ - { - message: 'Query root type must be provided.', - locations: [{ line: 2, column: 7 }], - }, - ]); - }); - it('rejects a Schema whose query root type is not an Object type', () => { const schema = buildSchema(` input Query { @@ -2582,8 +2553,6 @@ describe('assertValidSchema', () => { it('include multiple errors into a description', () => { const schema = buildSchema('type SomeType'); expect(() => assertValidSchema(schema)).to.throw(dedent` - Query root type must be provided. - Type SomeType must define one or more fields.`); }); }); diff --git a/src/type/validate.js b/src/type/validate.js index 010ed3549e..0a3f6da8ec 100644 --- a/src/type/validate.js +++ b/src/type/validate.js @@ -105,9 +105,7 @@ class SchemaValidationContext { function validateRootTypes(context) { const schema = context.schema; const queryType = schema.getQueryType(); - if (!queryType) { - context.reportError('Query root type must be provided.', schema.astNode); - } else if (!isObjectType(queryType)) { + if (queryType && !isObjectType(queryType)) { context.reportError( `Query root type must be Object type, it cannot be ${inspect( queryType,