graphql-dotnet / conventions

GraphQL Conventions Library for .NET
MIT License
233 stars 63 forks source link

"Unexpected type: " error #197

Closed K-Pavlov closed 4 years ago

K-Pavlov commented 4 years ago

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 4 years ago

Does changing the following make any difference?

-public partial class CoreQuery
+public class CoreQuery
K-Pavlov commented 4 years ago

@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 4 years ago

Fix in: https://github.com/graphql-dotnet/conventions/pull/205

Thanks