File tree Expand file tree Collapse file tree
test/groovy/graphql/validation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public Object coerceLiteral(Object input) {
3333 if (!(input instanceof EnumValue )) return null ;
3434 EnumValue enumValue = (EnumValue ) input ;
3535 GraphQLEnumValueDefinition enumValueDefinition = valueDefinitionMap .get (enumValue .getName ());
36+ if (enumValueDefinition == null ) return null ;
3637 if (enumValueDefinition .getValue () != null ) return enumValueDefinition .getValue ();
3738 return enumValueDefinition .getValue ();
3839 }
Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ private void enterImpl(ObjectField objectField) {
127127 GraphQLInputType inputType = null ;
128128 if (objectType instanceof GraphQLInputObjectType ) {
129129 GraphQLInputObjectField inputField = ((GraphQLInputObjectType ) objectType ).getField (objectField .getName ());
130- inputType = inputField .getType ();
130+ if (inputField != null )
131+ inputType = inputField .getType ();
131132 }
132133 addInputType (inputType );
133134 }
Original file line number Diff line number Diff line change @@ -98,13 +98,20 @@ class ValidationUtilTest extends Specification {
9898 validationUtil. isValidLiteralValue(new EnumValue (" PLUTO" ), enumType)
9999 }
100100
101- def " invalid enum" () {
101+ def " invalid enum value " () {
102102 given :
103103 def enumType = GraphQLEnumType . newEnum(). name(" enumType" ). value(" PLUTO" ). build()
104104 expect :
105105 ! validationUtil. isValidLiteralValue(new StringValue (" MARS" ), enumType)
106106 }
107107
108+ def " invalid enum name" () {
109+ given :
110+ def enumType = GraphQLEnumType . newEnum(). name(" enumType" ). value(" PLUTO" ). build()
111+ expect :
112+ ! validationUtil. isValidLiteralValue(new EnumValue (" MARS" ), enumType)
113+ }
114+
108115 def " a valid ObjectValue" () {
109116 given :
110117 def inputObjectType = GraphQLInputObjectType . newInputObject()
You can’t perform that action at this time.
0 commit comments