type Query {
cards: [CreditCard!]!
card(Id: ID!): CreditCard
}
type CreditCard {
id: ID!
name: String!
IssuedBy: String
}
Configure middleware
using HotChocolate;
using HotChocolate.AspNetCore;
using HotChocolate.Execution.Configuration;
// this enables you to use DataLoader in your resolvers.
services.AddDataLoaderRegistry();
// Add GraphQL Services
var queryExecutionOptions = new QueryExecutionOptions
{
TracingPreference = TracingPreference.OnDemand
};
if (_environment.IsDevelopment())
{
queryExecutionOptions.TracingPreference = TracingPreference.Always;
queryExecutionOptions.IncludeExceptionDetails = true;
_logger.LogInformation(" *** LogInformation: In DEV Environment");
}
// Create our schema
var schemaDef = File.ReadAllText("schema.graphql");
var schema = Schema.Create(schemaDef, ConfigureSchema);
services.AddGraphQL(schema, queryExecutionOptions);
app.UseGraphQL();
app.UsePlayground();