ChilliCream / graphql-workshop

Getting started with GraphQL on ASP.NET Core and Hot Chocolate - Workshop
465 stars 199 forks source link

The field `id` does not exist on the type `CommandsConnection`. #100

Closed bardhyliis closed 2 years ago

bardhyliis commented 2 years ago

Full error:

{ "errors": [ { "message": "The field id does not exist on the type CommandsConnection.", "locations": [ { "line": 59, "column": 9 } ], "path": [ "addCommandsIdentifier", "commandsIdentifier", "commands" ], "extensions": { "type": "CommandsConnection", "field": "id", "responseName": "id", "specifiedBy": "http://spec.graphql.org/October2021/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types" } }, { "message": "The field content does not exist on the type CommandsConnection.", "locations": [ { "line": 60, "column": 9 } ], "path": [ "addCommandsIdentifier", "commandsIdentifier", "commands" ], "extensions": { "type": "CommandsConnection", "field": "content", "responseName": "content", "specifiedBy": "http://spec.graphql.org/October2021/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types" } } ] }

the type:

` protected override void Configure(IObjectTypeDescriptor descriptor) { descriptor .ImplementsNode() .IdField(t => t.Id) .ResolveNode((ctx, id) => ctx.DataLoader().LoadAsync(id, ctx.RequestAborted));

        descriptor
            .Field(t => t.Commands)
            .ResolveWith<CommandResolvers>(t => t.GetCommandsAsync(default!, default!, default!, default))
            .UseDbContext<ApplicationDbContext>()
            .UsePaging<NonNullType<CommandType>>()
            .Name("commands");
    }

`

and the query:

public class CommandQueries { [UseApplicationDbContext] [UsePaging(typeof(NonNullType<CommandType>))] public IQueryable<Command> GetCommands([ScopedService] ApplicationDbContext context) => context.Commands; }

bardhyliis commented 2 years ago

Make sure you check the errors in the graphql document. 😫😫😫😫😫😫😫