Beispiel #1
0
        public override string PrintObject(IObjectGraphType type)
        {
            var isExtension = type.IsExtensionType();

            var interfaces            = type.ResolvedInterfaces.Select(x => x.Name).ToList();
            var delimiter             = " & ";
            var implementedInterfaces = interfaces.Count > 0
                ? " implements {0}".ToFormat(string.Join(delimiter, interfaces))
                : "";

            var federatedDirectives = PrintFederatedDirectives(type);

            var extended = isExtension ? "extend " : "";

            return(FormatDescription(type.Description) + "{1}type {2}{3}{4} {{{0}{5}{0}}}".ToFormat(Environment.NewLine, extended, type.Name, implementedInterfaces, federatedDirectives, PrintFields(type)));
        }
Beispiel #2
0
        public override string PrintObject(IObjectGraphType type)
        {
            // Do not return an empty query type: "Query { }" as it is not valid as part of the sdl.
            if (type != null && string.Equals(type.Name, "Query", StringComparison.Ordinal) && !type.Fields.Any(x => !IsFederatedType(x.ResolvedType.GetNamedType().Name)))
            {
                return(string.Empty);
            }

            var isExtension = type.IsExtensionType();

            var interfaces            = type.ResolvedInterfaces.List.Select(x => x.Name).ToList();
            var delimiter             = " & ";
            var implementedInterfaces = interfaces.Count > 0
                ? " implements {0}".ToFormat(string.Join(delimiter, interfaces))
                : "";

            var federatedDirectives = PrintFederatedDirectives(type);

            var extended = isExtension ? "extend " : "";

            return(FormatDescription(type.Description) + "{1}type {2}{3}{4} {{{0}{5}{0}}}".ToFormat(Environment.NewLine, extended, type.Name, implementedInterfaces, federatedDirectives, PrintFields(type)));
        }