private string PrintDirective(GraphQLDirectiveType directive) { return (PrintDescription(directive.Description) + $"directive @{directive.Name}{this.PrintArguments(directive.GetArguments())}" + $" on {string.Join(" | ", directive.Locations)}"); }
public void AddOrReplaceDirective(GraphQLDirectiveType directive) { if (this.directives.ContainsKey(directive.Name)) { this.directives.Remove(directive.Name); } this.directives.Add(directive.Name, directive); }
private List <GraphQLArgument> GetArgumentsFromDirectiveDefinition(GraphQLDirective directive, GraphQLDirectiveType directiveInfo) { if (directiveInfo == null || directiveInfo.Arguments?.Count == 0) { return(null); } return(this.MergeArgumentsWithDefault(directive.Arguments, directiveInfo.Arguments)); }
private void CheckDirectiveArgument(GraphQLArgument node, GraphQLDirectiveType directiveType, string argumentName) { var arguments = directiveType.GetArguments(); if (arguments.Any(e => e.Name == argumentName)) { return; } var errorMessage = this.ComposeUnknownDirectiveArgumentMessage( argumentName, directiveType.Name, StringUtils.SuggestionList(argumentName, arguments.Select(e => e.Name))); this.Errors.Add(new GraphQLException(errorMessage, new[] { node })); }
public void SetUp() { this.schema = new TestSchema(); this.testDirective = Substitute.For <GraphQLDirectiveType>( "test", "some description", DirectiveLocation.FIELD); this.testDirective.PreExecutionIncludeFieldIntoResult(null, null) .ReturnsForAnyArgs(true); this.testDirective.PostExecutionIncludeFieldIntoResult(null, null, null, null) .ReturnsForAnyArgs(true); this.testDirective.GetResolver(Arg.Any <Func <Task <object> > >(), Arg.Any <object>()) .Returns((Expression <Func <object> >)(() => "modified")); this.schema.AddOrReplaceDirective(this.testDirective); }
public void AddOrReplaceDirective(GraphQLDirectiveType directive) { this.SchemaRepository.AddOrReplaceDirective(directive); }