Schema Creation

To create a new schema we need to supply a base context type. This base type is used as the base for top-level query fields. DemoContext is our base query context for the schema.

// Using EntityGraphQL.AspNet extension method to add the schema auto-populated from the base query type. Schema has types and fields built from DemoContext. See optional arguments for customizing the behavior. services.AddGraphQLSchemaDemoContext>(options =>   options.ConfigureSchema = (schema) =>   // configure schema here >; >);  // Create a blank schema with the base query type. Schema has no types or fields yet. services.AddGraphQLSchemaDemoContext>(options =>   options.AutoBuildSchemaFromContext = false;  options.ConfigureSchema = (schema) =>   // configure schema here >; >); 

If you need to create a schema outside of ASP.NET.

// Create a schema auto-populated from the base query type. Schema has types and fields built from DemoContext. See optional arguments for customizing the behavior. var schema = new SchemaBuilder.FromObjectDemoContext>();  // Create a blank schema with the base query type. Schema has no types or fields yet. var schema = new SchemaProviderDemoContext>(); 

Adding Types​

Now we need to add some types to our schema which we will use as return types for fields. The most common GraphQL types you will deal with are