public void IntrospectedVirtualType_HasATypeNameMetaField() { var serverBuilder = new TestServerBuilder(TestOptions.UseCodeDeclaredNames) .AddGraphType <SodaCanBuildingController>(); var server = serverBuilder.Build(); var schema = new IntrospectedSchema(server.Schema); schema.Rebuild(); var graphType = schema.FindGraphType("Query_buildings") as IObjectGraphType; var typeNameField = graphType.Fields.FirstOrDefault(x => x.Name == Constants.ReservedNames.TYPENAME_FIELD); Assert.IsNotNull(typeNameField); }
public void IntrospectedSchema_PropertyCheck() { var serverBuilder = new TestServerBuilder(); serverBuilder.AddGraphType <string>(); var server = serverBuilder.Build(); var schema = new IntrospectedSchema(server.Schema); schema.Rebuild(); Assert.AreEqual(server.Schema.Name, schema.Name); Assert.IsNotNull(schema.FindGraphType(Constants.ScalarNames.STRING)); Assert.IsNotNull(schema.FindIntrospectedType(Constants.ScalarNames.STRING)); Assert.AreEqual(11, schema.KnownTypes.Count()); Assert.IsNotNull(schema.QueryType); Assert.IsNull(schema.MutationType); Assert.IsNull(schema.SubscriptionType); Assert.IsNotNull(schema.Directives); Assert.AreEqual(2, schema.Directives.Count()); // skip , include }
public void IntrospectedInputValueType_PropertyCheck() { var serverBuilder = new TestServerBuilder(TestOptions.UseCodeDeclaredNames) .AddGraphType <SodaCanBuildingController>(); var server = serverBuilder.Build(); var schema = new IntrospectedSchema(server.Schema); schema.Rebuild(); var graphType = schema.FindGraphType("Query_buildings") as IObjectGraphType; var spected = schema.FindIntrospectedType("Query_buildings"); Assert.IsNotNull(graphType); Assert.AreEqual(graphType.Name, spected.Name); Assert.AreEqual(graphType.Description, spected.Description); Assert.AreEqual(graphType.Kind, spected.Kind); Assert.AreEqual(1, spected.Fields.Count); var expectedField = graphType.Fields[nameof(SodaCanBuildingController.AddNewBuilding)]; var field = spected.Fields[0]; Assert.AreEqual(expectedField.Name, field.Name); Assert.AreEqual(1, field.Arguments.Count); var expectedArg = expectedField.Arguments["building"]; var arg1 = field.Arguments[0]; Assert.IsNotNull(arg1); Assert.AreEqual(expectedArg.Name, arg1.Name); Assert.AreEqual(expectedArg.Description, arg1.Description); Assert.AreEqual(expectedArg.DefaultValue, arg1.DefaultValue); // the type SodaCanBuildingData is used as input type "BuildngInput" for arg1 var introspectedInputType = schema.FindIntrospectedType("BuildingInput"); Assert.IsNotNull(introspectedInputType); Assert.AreEqual(introspectedInputType, arg1.IntrospectedGraphType); Assert.AreEqual(TypeKind.INPUT_OBJECT, introspectedInputType.Kind); Assert.AreEqual(3, introspectedInputType.InputFields.Count); var inputField1 = introspectedInputType.InputFields.Single(x => x.Name == "Name"); Assert.AreEqual(null, inputField1.Description); Assert.AreEqual(null, inputField1.DefaultValue); Assert.AreEqual(TypeKind.SCALAR, inputField1.IntrospectedGraphType.Kind); var inputField2 = introspectedInputType.InputFields.Single(x => x.Name == "Address"); Assert.AreEqual(null, inputField2.Description); Assert.AreEqual(null, inputField2.DefaultValue); Assert.AreEqual(TypeKind.SCALAR, inputField2.IntrospectedGraphType.Kind); var inputField3 = introspectedInputType.InputFields.Single(x => x.Name == "Capacity"); Assert.AreEqual(null, inputField3.Description); Assert.AreEqual(null, inputField3.DefaultValue); Assert.AreEqual(TypeKind.NON_NULL, inputField3.IntrospectedGraphType.Kind); Assert.AreEqual(TypeKind.ENUM, inputField3.IntrospectedGraphType.OfType.Kind); }