Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add identifiers to SDL enum, scalar, interface, and union types #633

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/absinthe/blueprint/schema/enum_type_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions lib/absinthe/language/enum_type_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/absinthe/language/interface_type_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/absinthe/language/scalar_type_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions lib/absinthe/language/union_type_definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 30 additions & 0 deletions test/absinthe/schema/notation/experimental/import_sdl_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down