From aed2d3fcfee0d0c9be68b3e8452376dcb9bff7bd Mon Sep 17 00:00:00 2001 From: Ko Date: Tue, 12 Aug 2025 12:16:29 +1000 Subject: [PATCH 1/2] according to GraphQL spec, enum is part of the valid input fields, which should not be skipped --- src/EntityGraphQL/Schema/SchemaIntrospection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/EntityGraphQL/Schema/SchemaIntrospection.cs b/src/EntityGraphQL/Schema/SchemaIntrospection.cs index 3a494d7f..409744b3 100644 --- a/src/EntityGraphQL/Schema/SchemaIntrospection.cs +++ b/src/EntityGraphQL/Schema/SchemaIntrospection.cs @@ -7,7 +7,6 @@ using EntityGraphQL.Directives; #endif - namespace EntityGraphQL.Schema; public static class SchemaIntrospection @@ -117,10 +116,6 @@ private static List BuildInputTypes(ISchemaProvider schema) if (field.ResolveExpression?.NodeType == System.Linq.Expressions.ExpressionType.Call) continue; - // Skipping ENUM type - if (field.ReturnType.TypeDotnet.IsEnum) - continue; - inputValues.Add(new InputValue(field.Name, BuildType(schema, field.ReturnType, field.ReturnType.TypeDotnet, true)) { Description = field.Description }); } From 28f6ca34209144adcce2b9c4976a3e4c92990433 Mon Sep 17 00:00:00 2001 From: Ko Date: Tue, 12 Aug 2025 12:47:22 +1000 Subject: [PATCH 2/2] Add unit test for enum input fields in GraphQL introspection --- .../IntrospectionTests/IntrospectionTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/tests/EntityGraphQL.Tests/IntrospectionTests/IntrospectionTests.cs b/src/tests/EntityGraphQL.Tests/IntrospectionTests/IntrospectionTests.cs index d01573bd..c287017a 100644 --- a/src/tests/EntityGraphQL.Tests/IntrospectionTests/IntrospectionTests.cs +++ b/src/tests/EntityGraphQL.Tests/IntrospectionTests/IntrospectionTests.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using EntityGraphQL.Schema; @@ -7,6 +8,45 @@ namespace EntityGraphQL.Tests; public class IntrospectionTests { + [Fact] + public void IncludeEnumInputField_Introspection() + { + var schema = SchemaBuilder.FromObject(); + + schema.AddInputType("EnumInputArgs", "args with enums").AddAllFields(); + + var gql = new QueryRequest + { + Query = + @"query { + __type(name: ""EnumInputArgs"") { + name + inputFields { + name + type { kind name ofType { kind name } } + } + } + }", + }; + + var result = schema.ExecuteRequestWithContext(gql, new TestDataContext(), null, null); + Assert.Null(result.Errors); + + var fields = (IEnumerable)((dynamic)result.Data!["__type"]!).inputFields; + Assert.Contains(fields, f => f.name == "unit"); + + var unitField = fields.First(f => f.name == "unit"); + Assert.Equal("NON_NULL", unitField.type.kind); + Assert.Equal("ENUM", unitField.type.ofType.kind); + Assert.Equal("HeightUnit", unitField.type.ofType.name); + } + + private class EnumInputArgs + { + public HeightUnit Unit { get; set; } + public DayOfWeek Day { get; set; } + } + [Fact] public void TestGraphiQLIntrospection() {