public async void TestResolveViaForeignServiceType_MixedTypes() { // arrange ISchema schema = SchemaBuilder.New() .AddApolloFederation() .AddQueryType <Query>() .Create(); IResolverContext context = CreateResolverContext(schema); // act var representations = new List <Representation> { new() { TypeName = "MixedFieldTypes", Data = new ObjectValueNode( new ObjectFieldNode("Id", "1"), new ObjectFieldNode("IntField", 25)) } }; // assert List <object?> result = await EntitiesResolver._Entities(schema, representations, context); MixedFieldTypes obj = Assert.IsType <MixedFieldTypes>(result[0]); Assert.Equal("1", obj.Id); Assert.Equal(25, obj.IntField); Assert.Equal("InternalValue", obj.InternalField); }
public async void TestResolveViaEntityResolver() { ISchema schema = SchemaBuilder.New() .AddApolloFederation() .AddQueryType <Query>() .Create(); IResolverContext context = CreateResolverContext(schema); // act var representations = new List <Representation> { new() { TypeName = "TypeWithReferenceResolver", Data = new ObjectValueNode(new ObjectFieldNode("Id", "1")) } }; // assert List <object?> result = await EntitiesResolver._Entities(schema, representations, context); TypeWithReferenceResolver obj = Assert.IsType <TypeWithReferenceResolver>(result[0]); Assert.Equal("1", obj.Id); Assert.Equal("SomeField", obj.SomeField); }
public async void TestResolveViaEntityResolver_NoResolverFound() { ISchema schema = SchemaBuilder.New() .AddApolloFederation() .AddQueryType <Query>() .Create(); IResolverContext context = CreateResolverContext(schema); // act var representations = new List <Representation> { new() { TypeName = "TypeWithoutRefResolver", Data = new ObjectValueNode() } }; // assert Task ShouldThrow() => EntitiesResolver._Entities(schema, representations, context); await Assert.ThrowsAsync <SchemaException>(ShouldThrow); }