Skip to content

Commit

Permalink
Resolved #1079
Browse files Browse the repository at this point in the history
  • Loading branch information
promontis committed Sep 17, 2019
1 parent 79dbb2e commit b486249
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Core/Types/Types/Descriptors/ArgumentDescriptor.cs
Expand Up @@ -83,6 +83,13 @@ public new IArgumentDescriptor Type<TInputType>()
return this;
}

public new IArgumentDescriptor Type(
Type type)
{
base.Type(type);
return this;
}

public new IArgumentDescriptor DefaultValue(IValueNode value)
{
base.DefaultValue(value);
Expand Down
14 changes: 14 additions & 0 deletions src/Core/Types/Types/Descriptors/ArgumentDescriptorBase~1.cs
Expand Up @@ -45,6 +45,20 @@ public void Type<TInputType>()
TypeContext.Input);
}

public void Type(Type type)
{
if (Context.Inspector.IsSchemaType(type)
&& !typeof(IInputType).IsAssignableFrom(type))
{
throw new ArgumentException(
TypeResources.ArgumentDescriptor_InputTypeViolation);
}

Definition.SetMoreSpecificType(
type,
TypeContext.Input);
}

public void Type<TInputType>(TInputType inputType)
where TInputType : class, IInputType
{
Expand Down
10 changes: 9 additions & 1 deletion src/Core/Types/Types/Descriptors/DirectiveArgumentDescriptor.cs
@@ -1,4 +1,5 @@
using System.Reflection;
using System;
using System.Reflection;
using HotChocolate.Language;
using HotChocolate.Types.Descriptors.Definitions;

Expand Down Expand Up @@ -71,6 +72,13 @@ public new IDirectiveArgumentDescriptor Type<TInputType>()
return this;
}

public new IDirectiveArgumentDescriptor Type(
Type type)
{
base.Type(type);
return this;
}

public new IDirectiveArgumentDescriptor DefaultValue(
IValueNode value)
{
Expand Down
8 changes: 7 additions & 1 deletion src/Core/Types/Types/Descriptors/InputFieldDescriptor.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using HotChocolate.Language;
using HotChocolate.Types.Descriptors.Definitions;
Expand Down Expand Up @@ -71,6 +71,12 @@ public new IInputFieldDescriptor Type(ITypeNode typeNode)
return this;
}

public new IInputFieldDescriptor Type(Type type)
{
base.Type(type);
return this;
}

public IInputFieldDescriptor Ignore()
{
Definition.Ignore = true;
Expand Down
8 changes: 7 additions & 1 deletion src/Core/Types/Types/Descriptors/InterfaceFieldDescriptor.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Reflection;
using HotChocolate.Language;
Expand Down Expand Up @@ -125,6 +125,12 @@ public new IInterfaceFieldDescriptor Type(ITypeNode type)
return this;
}

public new IInterfaceFieldDescriptor Type(Type type)
{
base.Type(type);
return this;
}

public new IInterfaceFieldDescriptor Argument(
NameString name,
Action<IArgumentDescriptor> argument)
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Types/Types/Descriptors/ObjectFieldDescriptor.cs
Expand Up @@ -141,6 +141,12 @@ public new IObjectFieldDescriptor Type(ITypeNode typeNode)
return this;
}

public new IObjectFieldDescriptor Type(Type type)
{
base.Type(type);
return this;
}

public new IObjectFieldDescriptor Argument(
NameString argumentName,
Action<IArgumentDescriptor> argumentDescriptor)
Expand Down
14 changes: 14 additions & 0 deletions src/Core/Types/Types/Descriptors/OutputFieldDescriptorBase.cs
Expand Up @@ -55,6 +55,20 @@ protected void Type<TOutputType>()
TypeContext.Output);
}

protected void Type(Type type)
{
if (Context.Inspector.IsSchemaType(type)
&& !typeof(IOutputType).IsAssignableFrom(type))
{
throw new ArgumentException(
TypeResources.ObjectFieldDescriptorBase_FieldType);
}

Definition.SetMoreSpecificType(
type,
TypeContext.Output);
}

protected void Type<TOutputType>(TOutputType outputType)
where TOutputType : class, IOutputType
{
Expand Down

0 comments on commit b486249

Please sign in to comment.