protected virtual DirectiveGraphType ToDirective(GraphQLDirectiveDefinition directiveDef) { var result = new DirectiveGraphType((string)directiveDef.Name.Value) { Description = directiveDef.Description?.Value.ToString() ?? directiveDef.Comment?.Text.ToString(), Repeatable = directiveDef.Repeatable, Arguments = ToQueryArguments(directiveDef.Arguments) }; if (directiveDef.Locations?.Count > 0) // just in case { foreach (var location in directiveDef.Locations) { if (__DirectiveLocation.Instance.Values.FindByName(location.Value)?.Value is DirectiveLocation l) { result.Locations.Add(l); } else { throw new InvalidOperationException($"Directive '{result.Name}' has an unknown directive location '{location.Value}'."); } } } return(result); }
private string PrintDirectiveDefinition(GraphQLDirectiveDefinition node) { var name = this.PrintName(node.Name); if (directivesToRemove.Contains(name)) { return(string.Empty); } var args = node.Arguments?.Select(this.Print); var locations = node.Locations?.Select(this.PrintName); return(this.Join(new[] { "directive @", name, args.All(e => !e.Contains(Environment.NewLine)) ? this.Wrap("(", this.Join(args, ", "), ")") : this.Wrap( $"({Environment.NewLine}", this.Indent(this.Join(args, Environment.NewLine)), $"{Environment.NewLine})"), " on ", this.Join(locations, " | ") })); }
protected virtual DirectiveGraphType ToDirective(GraphQLDirectiveDefinition directiveDef) { var locations = directiveDef.Locations.Select(l => ToDirectiveLocation(l.Value)); return(new DirectiveGraphType(directiveDef.Name.Value, locations) { Description = directiveDef.Comment?.Text, Arguments = ToQueryArguments(directiveDef.Arguments) }); }
protected virtual DirectiveGraphType ToDirective(GraphQLDirectiveDefinition directiveDef) { var locations = directiveDef.Locations.Select(l => ToDirectiveLocation(l.Value)); var directive = new DirectiveGraphType(directiveDef.Name.Value, locations); var arguments = directiveDef.Arguments.Select(ToArguments); directive.Arguments = new QueryArguments(arguments); return(directive); }
protected DirectiveType DirectiveType(GraphQLDirectiveDefinition definition) { var locations = definition.Locations .Select(location => (DirectiveLocation)System.Enum.Parse(typeof(DirectiveLocation), location.Value)) .ToList(); var args = Args(definition.Arguments); _builder.DirectiveType( definition.Name.Value, out var directiveType, locations, null, args.ToArray()); return(directiveType); }
protected DirectiveType DirectiveType(GraphQLDirectiveDefinition definition) { var locations = definition.Locations .Select(location => (DirectiveLocation)System.Enum.Parse(typeof(DirectiveLocation), location.Value)) .ToList(); var args = Args(definition.Arguments).ToList(); _builder.DirectiveType( definition.Name.Value, out var directiveType, locations, null, argsBuilder => args.ForEach(a => argsBuilder.Arg(a.Name, a.Type, a.DefaultValue, a.Description))); return(directiveType); }
private string PrintDirectiveDefinition(GraphQLDirectiveDefinition node) { var name = PrintName(node.Name); var args = node.Arguments?.Select(Print); var locations = node.Locations?.Select(PrintName); return(Join(new[] { "directive @", name, args.All(e => !e.Contains(Environment.NewLine)) ? Wrap("(", Join(args, ", "), ")") : Wrap( $"({Environment.NewLine}", Indent(Join(args, Environment.NewLine)), $"{Environment.NewLine})"), " on ", Join(locations, " | ") })); }