private bool DoTypesConflict(IGraphType type1, IGraphType type2)
        {
            if (type1 is ListGraphType type1List)
            {
                return(type2 is ListGraphType type2List?DoTypesConflict(type1List.ResolvedType, type2List.ResolvedType) : true);
            }

            if (type2 is ListGraphType)
            {
                return(true);
            }

            if (type1 is NonNullGraphType type1NonNull)
            {
                return(type2 is NonNullGraphType type2NonNull?DoTypesConflict(type1NonNull.ResolvedType, type2NonNull.ResolvedType) : true);
            }

            if (type2 is NonNullGraphType)
            {
                return(true);
            }

            if (type1.IsLeafType() || type2.IsLeafType())
            {
                return(!type1.Equals(type2));
            }

            return(false);
        }
예제 #2
0
        private void Field(IGraphType type, Field field, ValidationContext context)
        {
            if (type == null)
            {
                return;
            }

            if (type.IsLeafType())
            {
                if (field.SelectionSet != null && field.SelectionSet.Selections.Count > 0)
                {
                    var error = new ValidationError(context.OriginalQuery, "5.2.3", NoSubselectionAllowedMessage(field.Name, context.Print(type)), field.SelectionSet)
                    {
                        Path = context.TypeInfo.GetPath()
                    };
                    context.ReportError(error);
                }
            }
            else if (field.SelectionSet == null || field.SelectionSet.Selections.Count == 0)
            {
                var error = new ValidationError(context.OriginalQuery, "5.2.3", RequiredSubselectionMessage(field.Name, context.Print(type)), field)
                {
                    Path = context.TypeInfo.GetPath()
                };
                context.ReportError(error);
            }
        }
예제 #3
0
        private void Field(IGraphType type, Field field, ValidationContext context)
        {
            if (type == null)
            {
                return;
            }

            if (type.IsLeafType())
            {
                if (field.SelectionSet != null && field.SelectionSet.Selections.Count > 0)
                {
                    context.ReportError(new ScalarLeafsError(context, field.SelectionSet, field, type));
                }
            }
            else if (field.SelectionSet == null || field.SelectionSet.Selections.Count == 0)
            {
                context.ReportError(new ScalarLeafsError(context, field, type));
            }
        }
예제 #4
0
        private void Field(IGraphType type, Field field, ValidationContext context)
        {
            if (type == null)
            {
                return;
            }

            if (type.IsLeafType())
            {
                if (field.SelectionSet != null && field.SelectionSet.Selections.Any())
                {
                    var error = new ValidationError(context.OriginalQuery, "5.2.3", NoSubselectionAllowedMessage(field.Name, context.Print(type)), field.SelectionSet);
                    context.ReportError(error);
                }
            }
            else if(field.SelectionSet == null || !field.SelectionSet.Selections.Any())
            {
                var error = new ValidationError(context.OriginalQuery, "5.2.3", RequiredSubselectionMessage(field.Name, context.Print(type)), field);
                context.ReportError(error);
            }
        }