public void ResolverTypesDoNotOverwriteSchemaTypes() { // arrange var descriptor = ObjectFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor .Name("args") .Type <NonNullType <ListType <NonNullType <__InputValue> > > >() .Resolver(c => c.Parent <ObjectField>().Arguments); // assert ObjectFieldDefinition description = descriptor.CreateDefinition(); ITypeReference typeRef = description.Type; Assert.Equal( typeof(NonNullType <ListType <NonNullType <__InputValue> > >), Assert.IsType <ClrTypeReference>(typeRef).Type); }
public void SetResolverAndInferTypeIsAlwaysRecognisedAsDotNetType() { // arrange var descriptor = ObjectFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor .Type <__Type>() .Resolver(ctx => ctx.Schema .GetType <INamedType>(ctx.Argument <string>("type"))); // assert ObjectFieldDefinition description = descriptor.CreateDefinition(); ITypeReference typeRef = description.Type; Assert.Equal( typeof(__Type), Assert.IsType <ClrTypeReference>(typeRef).Type); Assert.NotNull(description.Resolver); }
public void Type_Syntax_Type_Null() { void Error() => ObjectFieldDescriptor.New(Context, "foo").Type((string)null); Assert.Throws <ArgumentNullException>(Error); }