protected override ISyntaxVisitorAction Enter( ObjectValueNode node, IDocumentValidatorContext context) { context.Names.Clear(); for (var i = 0; i < node.Fields.Count; i++) { ObjectFieldNode field = node.Fields[i]; if (!context.Names.Add(field.Name.Value)) { context.Errors.Add(context.InputFieldAmbiguous(field)); } } INamedType namedType = context.Types.Peek().NamedType(); if (namedType.IsLeafType()) { return(Enter((IValueNode)node, context)); } if (namedType is InputObjectType inputObjectType) { if (context.Names.Count >= inputObjectType.Fields.Count) { return(Continue); } for (var i = 0; i < inputObjectType.Fields.Count; i++) { IInputField field = inputObjectType.Fields[i]; if (field.Type.IsNonNullType() && field.DefaultValue.IsNull() && context.Names.Add(field.Name)) { context.Errors.Add( context.FieldIsRequiredButNull(node, field.Name)); } } } else { context.UnexpectedErrorsDetected = true; } return(Continue); }
protected override ISyntaxVisitorAction Enter( ObjectFieldNode node, IDocumentValidatorContext context) { if (context.Types.TryPeek(out IType type) && type.NamedType() is InputObjectType it && it.Fields.TryGetField(node.Name.Value, out InputField? field)) { if (field.Type.IsNonNullType() && node.Value.IsNull()) { context.Errors.Add( context.FieldIsRequiredButNull(node, field.Name)); } context.InputFields.Push(field); context.Types.Push(field.Type); return(Continue); }