Ejemplo n.º 1
0
 private string PrintDirective(GraphQLDirectiveType directive)
 {
     return
         (PrintDescription(directive.Description) +
          $"directive @{directive.Name}{this.PrintArguments(directive.GetArguments())}" +
          $" on {string.Join(" | ", directive.Locations)}");
 }
Ejemplo n.º 2
0
        public void AddOrReplaceDirective(GraphQLDirectiveType directive)
        {
            if (this.directives.ContainsKey(directive.Name))
            {
                this.directives.Remove(directive.Name);
            }

            this.directives.Add(directive.Name, directive);
        }
Ejemplo n.º 3
0
        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 }));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public void AddOrReplaceDirective(GraphQLDirectiveType directive)
 {
     this.SchemaRepository.AddOrReplaceDirective(directive);
 }