diff --git a/validator/schema.go b/validator/schema.go index 3242822f..a979bc41 100644 --- a/validator/schema.go +++ b/validator/schema.go @@ -37,7 +37,12 @@ func ValidateSchemaDocument(ast *SchemaDocument) (*Schema, *gqlerror.Error) { for _, ext := range ast.Extensions { def := schema.Types[ext.Name] if def == nil { - return nil, gqlerror.ErrorPosf(ext.Position, "Cannot extend type %s because it does not exist.", ext.Name) + schema.Types[ext.Name] = &Definition{ + Kind: ext.Kind, + Name: ext.Name, + Position: ext.Position, + } + def = schema.Types[ext.Name] } if def.Kind != ext.Kind { diff --git a/validator/schema_test.yml b/validator/schema_test.yml index b1d85c44..5bbf2ada 100644 --- a/validator/schema_test.yml +++ b/validator/schema_test.yml @@ -419,14 +419,12 @@ unions: locations: [{line: 1, column: 7}] type extensions: - - name: cannot extend non existant types + - name: can extend non existant types input: | extend type A { name: String } - error: - message: "Cannot extend type A because it does not exist." - locations: [{line: 1, column: 13}] + - name: cannot extend incorret type existant types input: |