Skip to content

Commit 3f7af3a

Browse files
committed
feat(spec): Add support for directive
1 parent 0f93c9b commit 3f7af3a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/absinthe/schema/prototype/notation.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ defmodule Absinthe.Schema.Prototype.Notation do
4545
on [:scalar]
4646
end
4747

48+
# https://spec.graphql.org/September2025/#sec--oneOf
49+
directive :one_of do
50+
description """
51+
The @oneOf built-in directive is used within the type system definition language to indicate an Input Object is a OneOf Input Object.
52+
53+
A OneOf Input Object is a special variant of Input Object where exactly one field must be set and non-null, all others being omitted.
54+
This is useful for representing situations where an input may be one of many different options.
55+
"""
56+
57+
repeatable false
58+
on [:input_field_definition]
59+
end
60+
4861
def pipeline(pipeline) do
4962
pipeline
5063
|> Absinthe.Pipeline.without(Absinthe.Phase.Schema.Validation.QueryTypeMustBeObject)

test/absinthe/introspection_test.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ defmodule Absinthe.IntrospectionTest do
6262
"onFragment" => true,
6363
"onOperation" => false
6464
},
65+
%{
66+
"description" => "The @oneOf built-in directive is used within the type system definition language to indicate an Input Object is a OneOf Input Object.\n\nA OneOf Input Object is a special variant of Input Object where exactly one field must be set and non-null, all others being omitted.\nThis is useful for representing situations where an input may be one of many different options.",
67+
"isRepeatable" => false,
68+
"locations" => ["INPUT_FIELD_DEFINITION"],
69+
"name" => "oneOf",
70+
"onField" => false,
71+
"onFragment" => false,
72+
"onOperation" => false
73+
},
6574
%{
6675
"description" =>
6776
"Directs the executor to skip this field or fragment when the `if` argument is true.",

0 commit comments

Comments
 (0)