diff --git a/lib/absinthe/blueprint/schema/enum_type_definition.ex b/lib/absinthe/blueprint/schema/enum_type_definition.ex index 460e609f1e..56f7eb57c4 100644 --- a/lib/absinthe/blueprint/schema/enum_type_definition.ex +++ b/lib/absinthe/blueprint/schema/enum_type_definition.ex @@ -23,6 +23,7 @@ defmodule Absinthe.Blueprint.Schema.EnumTypeDefinition do name: String.t(), values: [Blueprint.Schema.EnumValueDefinition.t()], directives: [Blueprint.Directive.t()], + identifier: atom, source_location: nil | Blueprint.SourceLocation.t(), # Added by phases flags: Blueprint.flags_t(), diff --git a/lib/absinthe/language/enum_type_definition.ex b/lib/absinthe/language/enum_type_definition.ex index 55dfcf4610..b120306f56 100644 --- a/lib/absinthe/language/enum_type_definition.ex +++ b/lib/absinthe/language/enum_type_definition.ex @@ -22,6 +22,7 @@ defmodule Absinthe.Language.EnumTypeDefinition do %Blueprint.Schema.EnumTypeDefinition{ name: node.name, description: node.description, + identifier: Macro.underscore(node.name) |> String.to_atom(), values: Absinthe.Blueprint.Draft.convert(node.values, doc), directives: Absinthe.Blueprint.Draft.convert(node.directives, doc), source_location: source_location(node) diff --git a/lib/absinthe/language/interface_type_definition.ex b/lib/absinthe/language/interface_type_definition.ex index 575fef1ef1..1e02c8e205 100644 --- a/lib/absinthe/language/interface_type_definition.ex +++ b/lib/absinthe/language/interface_type_definition.ex @@ -22,6 +22,7 @@ defmodule Absinthe.Language.InterfaceTypeDefinition do %Blueprint.Schema.InterfaceTypeDefinition{ name: node.name, description: node.description, + identifier: Macro.underscore(node.name) |> String.to_atom(), fields: Absinthe.Blueprint.Draft.convert(node.fields, doc), directives: Absinthe.Blueprint.Draft.convert(node.directives, doc), source_location: source_location(node) diff --git a/lib/absinthe/language/scalar_type_definition.ex b/lib/absinthe/language/scalar_type_definition.ex index 3b757ef08d..318578d64b 100644 --- a/lib/absinthe/language/scalar_type_definition.ex +++ b/lib/absinthe/language/scalar_type_definition.ex @@ -20,6 +20,7 @@ defmodule Absinthe.Language.ScalarTypeDefinition do %Blueprint.Schema.ScalarTypeDefinition{ name: node.name, description: node.description, + identifier: Macro.underscore(node.name) |> String.to_atom(), directives: Absinthe.Blueprint.Draft.convert(node.directives, doc), source_location: source_location(node) } diff --git a/lib/absinthe/language/union_type_definition.ex b/lib/absinthe/language/union_type_definition.ex index a04f092d62..ccf787c0d0 100644 --- a/lib/absinthe/language/union_type_definition.ex +++ b/lib/absinthe/language/union_type_definition.ex @@ -22,6 +22,7 @@ defmodule Absinthe.Language.UnionTypeDefinition do %Blueprint.Schema.UnionTypeDefinition{ name: node.name, description: node.description, + identifier: Macro.underscore(node.name) |> String.to_atom(), types: Absinthe.Blueprint.Draft.convert(node.types, doc), directives: Absinthe.Blueprint.Draft.convert(node.directives, doc), source_location: source_location(node) diff --git a/test/absinthe/schema/notation/experimental/import_sdl_test.exs b/test/absinthe/schema/notation/experimental/import_sdl_test.exs index 4bbfbbb92b..ec1d6187a6 100644 --- a/test/absinthe/schema/notation/experimental/import_sdl_test.exs +++ b/test/absinthe/schema/notation/experimental/import_sdl_test.exs @@ -15,6 +15,36 @@ defmodule Absinthe.Schema.Notation.Experimental.ImportSdlTest do posts(filter: PostFilter): [Post] admin: User! } + + type Comment { + author: User! + subject: Post! + } + + enum Category { + NEWS + OPINION + } + + enum PostState { + SUBMITTED + ACCEPTED + REJECTED + } + + interface Named { + name: String! + } + + interface Titled { + title: String! + } + + scalar A + scalar B + + union SearchResult = Post | User + union Content = Post | Comment """ # Read SDL from file manually at compile-time