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 directive locations for schema #743

Merged
merged 6 commits into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 6 additions & 1 deletion lib/absinthe/phase/schema/attach_directives.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ defmodule Absinthe.Phase.Schema.AttachDirectives do
[
%Absinthe.Type.Directive{
name: "deprecated",
locations: [:field_definition, :input_field_definition, :argument_definition],
locations: [
:field_definition,
:input_field_definition,
:argument_definition,
:enum_value
],
expand: &expand_deprecate/2
}
]
Expand Down
15 changes: 13 additions & 2 deletions lib/absinthe/type/built_ins/introspection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,19 @@ defmodule Absinthe.Type.BuiltIns.Introspection do
:field,
:fragment_definition,
:fragment_spread,
:inline_fragment
# TODO: Schema definitions to support Schema input
:inline_fragment,
:operation_definition,
bruce marked this conversation as resolved.
Show resolved Hide resolved
:schema,
:scalar,
:object,
:field_definition,
:interface,
:union,
:enum,
:enum_value,
:input_object,
:argument_definition,
:input_field_definition
]

object :__type do
Expand Down
14 changes: 13 additions & 1 deletion lib/absinthe/type/directive.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ defmodule Absinthe.Type.Directive do
defp do_on?(:fragment_definition, %Language.Fragment{}), do: true
defp do_on?(:fragment_spread, %Language.FragmentSpread{}), do: true
defp do_on?(:inline_fragment, %Language.InlineFragment{}), do: true
# TODO: Schema definitions to support Schema input
defp do_on?(:operation_definition, %Language.OperationDefinition{}), do: true
defp do_on?(:schema, %Language.SchemaDefinition{}), do: true
defp do_on?(:schema, %Language.SchemaDeclaration{}), do: true
defp do_on?(:scalar, %Language.ScalarTypeDefinition{}), do: true
defp do_on?(:object, %Language.ObjectTypeDefinition{}), do: true
defp do_on?(:field_definition, %Language.FieldDefinition{}), do: true
defp do_on?(:interface, %Language.InterfaceTypeDefinition{}), do: true
defp do_on?(:union, %Language.UnionTypeDefinition{}), do: true
defp do_on?(:enum, %Language.EnumTypeDefinition{}), do: true
defp do_on?(:enum_value, %Language.EnumValueDefinition{}), do: true
defp do_on?(:input_object, %Language.InputObjectTypeDefinition{}), do: true
defp do_on?(:argument_definition, %Language.InputValueDefinition{}), do: true
defp do_on?(:input_field_definition, %Language.InputValueDefinition{}), do: true
defp do_on?(_, _), do: false
end