private void SetupIntrospectionTypesAndField() { // evaluate Fields lazily so we don't end up in endless loop Type <Models.TypeElement>("__Type").ReplaceField("fields", new { includeDeprecated = false }, (t, p) => SchemaIntrospection.BuildFieldsForType(this, t.Name).Where(f => p.includeDeprecated ? f.IsDeprecated || !f.IsDeprecated : !f.IsDeprecated).ToList(), "Fields available on type"); ReplaceField("__schema", db => SchemaIntrospection.Make(this), "Introspection of the schema", "__Schema"); ReplaceField("__type", new { name = ArgumentHelper.Required <string>() }, (db, p) => SchemaIntrospection.Make(this).Types.Where(s => s.Name == p.name).First(), "Query a type by name", "__Type"); }
private void SetupIntrospectionTypesAndField() { var allTypeMappings = SchemaGenerator.DefaultTypeMappings.ToDictionary(k => k.Key, v => v.Value); // add the top level __schema field which is made _at runtime_ currently e.g. introspection could be faster foreach (var item in customTypeMappings) { allTypeMappings[item.Key] = item.Value; } var combinedMapping = new CombinedMapping(allTypeMappings, customScalarTypes); // evaluate Fields lazily so we don't end up in endless loop Type<Models.TypeElement>("__Type").ReplaceField("fields", new { includeDeprecated = false }, (t, p) => SchemaIntrospection.BuildFieldsForType(this, combinedMapping, t.Name).Where(f => p.includeDeprecated ? f.IsDeprecated || !f.IsDeprecated : !f.IsDeprecated).ToList(), "Fields available on type"); ReplaceField("__schema", db => SchemaIntrospection.Make(this, combinedMapping), "Introspection of the schema", "__Schema"); ReplaceField("__type", new { name = ArgumentHelper.Required<string>() }, (db, p) => SchemaIntrospection.Make(this, combinedMapping).Types.Where(s => s.Name == p.name).First(), "Query a type by name", "__Type"); }