0

I am testing HotChocolate using the starwars example .

I added Enityframework and sql nuggets and hooked everything up with a table named "Merchants".

Until now everything works fine and I can query My merchants table using Graphiql .

My problem is when I add Merchant type in startup.cs like this :

    services.AddGraphQL(sp => SchemaBuilder.New()
        .AddServices(sp)

        // Adds the authorize directive and
        // enable the authorization middleware.
        .AddAuthorizeDirectiveType()

        .AddQueryType<QueryType>()
        .AddMutationType<MutationType>()
        .AddSubscriptionType<SubscriptionType>()
        .AddType<HumanType>()
        .AddType<DroidType>()
        .AddType<EpisodeType>()
        .AddType<MerchantType>() ///----> My addition
        .Create(),
        new QueryExecutionOptions
        {
            TracingPreference = TracingPreference.Always
        });

this is the type

 public class MerchantType : ObjectType<Merchant>
    {
        protected override void Configure(IObjectTypeDescriptor<Merchant> descriptor)
        {
            descriptor.Name("Merchant");

            descriptor.Field("Id")
                .Type<NonNullType<StringType>>();

            descriptor.Field("MerchantName")
                .Type<StringType>();

            descriptor.Field("MerchantSlogan")
                .Type<StringType>();


        }
    }

I get this error as soon as my app starts :

HotChocolate.SchemaException: 'Multiple schema errors occured:
The field `Merchant.Id` has no resolver. - Type: Merchant
The field `Merchant.MerchantName` has no resolver. - Type: Merchant
The field `Merchant.MerchantSlogan` has no resolver. - Type: Merchant
'

DO I need to implement a resolver for every field ? even though i am not changing the data .

user2596181
  • 103
  • 2
  • 8

1 Answers1

0

My mistake, I replaced .Field("Id") to Field(t => t.Id) and all fields .

user2596181
  • 103
  • 2
  • 8