Skip to content

Commit f1efcd3

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

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ defmodule Absinthe.IntrospectionTest do
6262
"onFragment" => true,
6363
"onOperation" => false
6464
},
65+
%{
66+
"description" =>
67+
"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.",
68+
"isRepeatable" => false,
69+
"locations" => ["INPUT_FIELD_DEFINITION"],
70+
"name" => "oneOf",
71+
"onField" => false,
72+
"onFragment" => false,
73+
"onOperation" => false
74+
},
6575
%{
6676
"description" =>
6777
"Directs the executor to skip this field or fragment when the `if` argument is true.",

0 commit comments

Comments
 (0)