Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public static Schema Load(
leafTypes,
typeInfos);

// Forward input object extensions to the schema builder
var inputExtensions = document.Definitions
.OfType<InputObjectTypeExtensionNode>()
.ToList();
if (inputExtensions.Count > 0)
{
builder.AddDocument(new DocumentNode(inputExtensions));
}

if (!noStore)
{
CollectGlobalEntityPatterns(
Expand Down Expand Up @@ -77,13 +86,23 @@ public static Schema Load(
}
}

builder.AddDocument(document);
// Filter out @rename directive declaration to prevent a duplicate-type
// error when the user's schema already declares it. We always register
// RenameDirectiveType programmatically so its C# binding is correct.
var definitions = document.Definitions
.Where(d => !(d is DirectiveDefinitionNode dd && dd.Name.Value == "rename"))
.ToList();
var docToAdd = definitions.Count == document.Definitions.Count
? document
: new DocumentNode(definitions);
builder.AddDocument(docToAdd);
}
}

AddDefaultScalarInfos(builder, leafTypes);

return builder
.AddDirectiveType<RenameDirectiveType>()
.ModifyOptions(
o =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,20 @@ scalar Upload
",
"extend schema @key(fields: \"id\")");
}

[Fact]
public void Input_Field_Renamed_Via_Extension_Has_CSharp_Property_Name_With_Original_Wire_Key()
{
AssertResult(
"""mutation SetFoo($input: FooInput!) { setFoo(input: $input) }""",
"""
type Query { noop: String }
type Mutation { setFoo(input: FooInput!): Boolean }
input FooInput { value: String }
""",
"""
extend schema @key(fields: "id")
extend input FooInput { equals: String @rename(name: "EqualsValue") }
""");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,19 @@ query GetField1 {
}
""");
}

[Fact]
public void Enum_Value_With_Rename_Has_Renamed_CSharp_Member_And_Original_Wire_Value()
{
AssertResult(
"""query GetStatus { status }""",
"""
type Query { status: Status! }
enum Status {
ACTIVE @rename(name: "Active")
INACTIVE @rename(name: "Inactive")
}
directive @rename(name: String!) on INPUT_FIELD_DEFINITION | INPUT_OBJECT | ENUM | ENUM_VALUE
""");
}
}
Loading
Loading