graphql-dotnet/conventions

"Unexpected type: " error

K-Pavlov opened this issue · 3 comments

Having this Schema and request

    internal class Program
    {
        private static async Task Main(string[] args)
        {
            var res = await GraphQLEngine.New<CoreQuery>()
                 .NewExecutor()
                 .WithQueryString("query { node { id } }")
                 .Execute();

            res.Errors.ToList().ForEach(x => Console.WriteLine(x.ToString()));
        }
    }

    public partial class CoreQuery
    {
        public INode Node()
        {
            return new Test();
        }

        public Test A()
        {
            return null;
        }

        public NonNull<Test> B()
        {
            return null;
        }
    }

    public class Test : INode
    {
        public Id Id => Id.New<Test>(1);
    }

Results in a "Unexpected type: " error from GraphQL.NET. This seems very similar to #187, but the same fix breaks a lot of tests;
The contents of the type cache seem wrong to me:
1
2
3

I am not really sure what the real issue is here and what a suitable fix would be here (and why this comes up after so many working cases)

tlil commented

Does changing the following make any difference?

-public partial class CoreQuery
+public class CoreQuery

@tlil No, not really; Switching the name of the A and B methods fixes it though, because of alphabetic sorting and the way a type is chosen (experienced the same behavior with #187)

tlil commented

Fix in:
#205

Thanks