Exemplo n.º 1
0
        protected override void Configure(IDirectiveTypeDescriptor <LanguageDirective> descriptor)
        {
            descriptor.Name("language");
            descriptor.Location(DirectiveLocation.Object);
            descriptor.Location(DirectiveLocation.Query);
            descriptor.Argument(x => x.Name);

            descriptor.Use <LanguageDirectiveMiddleware>();
        }
Exemplo n.º 2
0
 protected override void Configure(
     IDirectiveTypeDescriptor <CustomDirective> descriptor)
 {
     descriptor.Name("Custom");
     descriptor.Location(DirectiveLocation.Enum);
     descriptor.Location(DirectiveLocation.Field);
     descriptor.Use(next => context => Task.CompletedTask);
     descriptor.BindArgumentsImplicitly().BindArgumentsExplicitly();
 }
 protected override void Configure(
     IDirectiveTypeDescriptor descriptor)
 {
     descriptor.Name("dummy_arg");
     descriptor.Argument("a").Type <StringType>();
     descriptor.Location(DirectiveLocation.Enum);
     descriptor.Location(DirectiveLocation.FieldDefinition);
     descriptor.Location(DirectiveLocation.ArgumentDefinition);
 }
Exemplo n.º 4
0
        public static IDirectiveTypeDescriptor FieldsArgument(
            this IDirectiveTypeDescriptor descriptor)
        {
            descriptor
            .Argument(Fields)
            .Type <NonNullType <FieldSetType> >();

            return(descriptor);
        }
Exemplo n.º 5
0
 protected override void Configure(
     IDirectiveTypeDescriptor descriptor)
 {
     descriptor.Name("dummy_rep");
     descriptor.Repeatable();
     descriptor.Location(DirectiveLocation.Enum);
     descriptor.Location(DirectiveLocation.FieldDefinition);
     descriptor.Location(DirectiveLocation.ArgumentDefinition);
 }
Exemplo n.º 6
0
 protected override void Configure(
     IDirectiveTypeDescriptor <CDirective> descriptor)
 {
     descriptor.Name("c");
     descriptor.Location(DirectiveLocation.Field);
     descriptor.Use(_ => context =>
     {
         var s           = context.Directive.ToObject <CDirective>().Append;
         context.Result += s;
         return(default);
Exemplo n.º 7
0
 protected override void Configure(IDirectiveTypeDescriptor <RenameDirective> descriptor)
 {
     descriptor.Name("rename");
     descriptor.Argument(t => t.Name).Type <NonNullType <StringType> >();
     descriptor.Location(
         DirectiveLocation.InputFieldDefinition |
         DirectiveLocation.InputObject |
         DirectiveLocation.Enum |
         DirectiveLocation.EnumValue);
 }
        protected override void Configure(IDirectiveTypeDescriptor <OperationDirective> descriptor)
        {
            descriptor
            .Name("operation")
            .Location(DirectiveLocation.Object | DirectiveLocation.Schema);

            descriptor
            .Argument(t => t.Operations)
            .Type <ListType <NonNullType <OperationKindType> > >();
        }
Exemplo n.º 9
0
 protected override void Configure(IDirectiveTypeDescriptor descriptor)
 {
     descriptor.Name("executeValidation");
     descriptor.Location(Types.DirectiveLocation.Object);
     descriptor.Use(next => context =>
     {
         Validate(context);
         return(next.Invoke(context));
     });
 }
Exemplo n.º 10
0
        protected override void Configure(
            IDirectiveTypeDescriptor <AuthorizeDirective> descriptor)
        {
            descriptor.Name("authorize");

            descriptor.Location(DirectiveLocation.Object)
            .Location(DirectiveLocation.FieldDefinition);

            descriptor.Middleware(
                next => context => AuthorizeAsync(context, next));
        }
Exemplo n.º 11
0
        protected override void Configure(
            IDirectiveTypeDescriptor <ComputedDirective> descriptor)
        {
            descriptor.Name(DirectiveNames.Computed);

            descriptor.Location(DirectiveLocation.FieldDefinition);

            descriptor.Argument(t => t.DependantOn)
            .Name(DirectiveFieldNames.Computed_DependantOn)
            .Type <ListType <NonNullType <NameType> > >()
            .Description(StitchingResources.ComputedDirectiveType_Description);
        }
Exemplo n.º 12
0
        protected override void Configure(
            IDirectiveTypeDescriptor <AuthorizeDirective> descriptor)
        {
            descriptor.Name("authorize");

            descriptor.Location(DirectiveLocation.Object)
            .Location(DirectiveLocation.FieldDefinition);

            descriptor.Repeatable();

            descriptor.Use <AuthorizeMiddleware>();
        }
Exemplo n.º 13
0
 protected override void Configure(IDirectiveTypeDescriptor descriptor)
 {
     descriptor.Name("custom");
     descriptor.Location(DirectiveLocation.Field);
     descriptor.Argument("d").Type <DateTimeType>();
     descriptor.Use(next => ctx =>
     {
         ctx.Result = ctx.Directive.GetArgument <DateTime>("d")
                      .ToUniversalTime();
         return(next.Invoke(ctx));
     });
 }
        public void DeclareEmptyName()
        {
            // arrange
            var descriptor = new DirectiveTypeDescriptor();

            // act
            IDirectiveTypeDescriptor desc = descriptor;
            Action a = () => desc.Name(string.Empty);

            // assert
            Assert.Throws <ArgumentException>(a);
        }
Exemplo n.º 15
0
        protected override void Configure(IDirectiveTypeDescriptor <FilterableDirective> descriptor)
        {
            descriptor
            .Name("filterable")
            .Location(DirectiveLocation.FieldDefinition |
                      DirectiveLocation.Schema |
                      DirectiveLocation.Scalar);

            descriptor
            .Argument(t => t.Operations)
            .Type <ListType <NonNullType <FilterOperationType> > >();
        }
Exemplo n.º 16
0
        protected override void Configure(IDirectiveTypeDescriptor<SortableDirective> descriptor)
        {
            descriptor
                .Name("sortable")
                .Location(DirectiveLocation.FieldDefinition |
                    DirectiveLocation.Schema |
                    DirectiveLocation.Scalar);

            descriptor
                .Argument(t => t.Direction)
                .Type<SortDirectionType>();
        }
        public void MethodsAreNotAllowedAsArguments()
        {
            // arrange
            var descriptor = new DirectiveTypeDescriptor <CustomDirective>();

            // act
            IDirectiveTypeDescriptor <CustomDirective> desc = descriptor;
            Action action = () => desc.Argument(t => t.Foo()).Ignore();

            // assert
            Assert.Throws <ArgumentException>(action);
        }
Exemplo n.º 18
0
 protected override void Configure(
     IDirectiveTypeDescriptor descriptor)
 {
     descriptor.Name("appendString");
     descriptor.Location(DirectiveLocation.Field);
     descriptor.Argument("s").Type <NonNullType <StringType> >();
     descriptor.Middleware(next => context =>
     {
         context.Result = context.Result +
                          context.Directive.GetArgument <string>("s");
         return(next.Invoke(context));
     });
 }
Exemplo n.º 19
0
 protected override void Configure(IDirectiveTypeDescriptor descriptor)
 {
     descriptor.Name("append");
     descriptor.Location(DirectiveLocation.Field);
     descriptor.Use(next => async context =>
     {
         await next(context);
         if (context.Result is string)
         {
             context.Result += " --";
         }
     });
 }
Exemplo n.º 20
0
 protected override void Configure(IDirectiveTypeDescriptor <ADirective> descriptor)
 {
     descriptor.Name("a");
     descriptor.Location(DirectiveLocation.Object);
     descriptor.Location(DirectiveLocation.Interface);
     descriptor.Location(DirectiveLocation.FieldDefinition);
     descriptor.Use(next => context =>
     {
         var s          = context.Directive.ToObject <ADirective>().Append;
         context.Result = context.Result + s;
         return(next.Invoke(context));
     });
 }
Exemplo n.º 21
0
 protected override void Configure(
     IDirectiveTypeDescriptor <NameDirective> descriptor)
 {
     descriptor.Name("name")
     .Location(DirectiveLocation.EnumValue)
     .Location(DirectiveLocation.Object)
     .Location(DirectiveLocation.Interface)
     .Location(DirectiveLocation.Union)
     .Location(DirectiveLocation.Enum)
     .Location(DirectiveLocation.InputObject)
     .Location(DirectiveLocation.Scalar)
     .Argument(t => t.Value).Type <NonNullType <StringType> >();
 }
        public void DeclareName()
        {
            // arrange
            var descriptor = new DirectiveTypeDescriptor();

            // act
            IDirectiveTypeDescriptor desc = descriptor;

            desc.Name("Foo");

            // assert
            Assert.Equal("Foo", descriptor.CreateDescription().Name);
        }
Exemplo n.º 23
0
 private static void DeclareLocations(
     IDirectiveTypeDescriptor typeDescriptor,
     DirectiveDefinitionNode node)
 {
     foreach (NameNode location in node.Locations)
     {
         if (Enum.TryParse(location.Value, true,
                           out DirectiveLocation parsedLocation))
         {
             typeDescriptor.Location(parsedLocation);
         }
     }
 }
Exemplo n.º 24
0
        private static void DeclareArguments(
            IDirectiveTypeDescriptor typeDescriptor,
            DirectiveDefinitionNode node)
        {
            foreach (InputValueDefinitionNode inputField in node.Arguments)
            {
                IDirectiveArgumentDescriptor descriptor = typeDescriptor
                                                          .Argument(inputField.Name.Value)
                                                          .Description(inputField.Description?.Value)
                                                          .Type(inputField.Type)
                                                          .SyntaxNode(inputField);

                if (inputField.DefaultValue is { })
Exemplo n.º 25
0
        protected override void Configure(
            IDirectiveTypeDescriptor <ExportDirective> descriptor)
        {
            descriptor.Name(ExportDirectiveHelper.Name);
            descriptor.Location(DirectiveLocation.Field);

            descriptor.Argument(t => t.As).Type <StringType>();

            descriptor.Use(next => async context =>
            {
                await next(context).ConfigureAwait(false);
                context.ExportValueAsVariable();
            });
        }
        public void InferName()
        {
            // arrange
            var descriptor = new DirectiveTypeDescriptor <CustomDirective>();

            // act
            IDirectiveTypeDescriptor desc = descriptor;

            // assert
            DirectiveTypeDescription description =
                descriptor.CreateDescription();

            Assert.Equal("CustomDirective", description.Name);
        }
Exemplo n.º 27
0
    protected override void Configure(IDirectiveTypeDescriptor descriptor)
    {
        descriptor
        .Name(WellKnownDirectives.Skip)
        .Description(TypeResources.SkipDirectiveType_TypeDescription)
        .Location(DirectiveLocation.Field)
        .Location(DirectiveLocation.FragmentSpread)
        .Location(DirectiveLocation.InlineFragment);

        descriptor
        .Argument(WellKnownDirectives.IfArgument)
        .Description(TypeResources.SkipDirectiveType_IfDescription)
        .Type <NonNullType <BooleanType> >();
    }
Exemplo n.º 28
0
        protected override void Configure(
            IDirectiveTypeDescriptor <SpecifiedByDirective> descriptor)
        {
            descriptor
            .Name(Names.SpecifiedBy)
            .Description(TypeResources.SpecifiedByDirectiveType_TypeDescription)
            .Location(DirectiveLocation.Scalar);

            descriptor
            .Argument(t => t.Url)
            .Name(Names.Url)
            .Description(TypeResources.SpecifiedByDirectiveType_UrlDescription)
            .Type <NonNullType <StringType> >();
        }
Exemplo n.º 29
0
 protected override void Configure(
     IDirectiveTypeDescriptor <CDirective> descriptor)
 {
     descriptor.Name("c");
     descriptor.Location(DirectiveLocation.Field);
     descriptor.Use(next => context =>
     {
         string s = context.Directive
                    .ToObject <CDirective>()
                    .Append;
         context.Result = context.Result + s;
         return(Task.CompletedTask);
     });
 }
Exemplo n.º 30
0
        protected override void Configure(IDirectiveTypeDescriptor <TypeNameDirective> descriptor)
        {
            descriptor
            .Name("typeName")
            .Location(DirectiveLocation.Object);

            descriptor
            .Argument(t => t.Name)
            .Type <NonNullType <StringType> >();

            descriptor
            .Argument(t => t.PluralName)
            .Type <StringType>();
        }