Creating a schema

Schema defines the structure against which your queries are executed.

See also

Schema creation includes following steps:

  1. Create instance of SchemaBuilder
  2. Create query root type
  3. Build schema

        public void Part1_CreateSchema()
            // 1. Create builder
            var builder = new SchemaBuilder();

            // 2. Create Query type from SDL by defining a type with 
            // name Query. This is by convention.
                type Query {
                    name: String

            // 3. Build schema
            var schema = builder.Build();

            // Assert that created schema matches the inputs
            // note: By convention the name on the Query root type is Query
            Assert.Equal("Query", schema.Query.Name);

            // Schema has methods for querying the fields of the type.
            // In this case assertion is done to check that "name" field exists
            // for Query type. Fields are key value pairs where key is the name
            // of the field and value is the actual field.
                fieldDef => fieldDef.Key == "name");