Skip to content
Merged
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
5 changes: 0 additions & 5 deletions src/EntityGraphQL/Schema/SchemaIntrospection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using EntityGraphQL.Directives;
#endif


namespace EntityGraphQL.Schema;

public static class SchemaIntrospection
Expand Down Expand Up @@ -117,10 +116,6 @@ private static List<TypeElement> 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 });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EntityGraphQL.Schema;
Expand All @@ -7,6 +8,45 @@ namespace EntityGraphQL.Tests;

public class IntrospectionTests
{
[Fact]
public void IncludeEnumInputField_Introspection()
{
var schema = SchemaBuilder.FromObject<TestDataContext>();

schema.AddInputType<EnumInputArgs>("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>)((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()
{
Expand Down