public static ISchemaBuilder AddDirectiveType(
     this ISchemaBuilder builder,
     string name,
     DirectiveLocation location,
     Func <IDirectiveTypeDescriptor, IDirectiveTypeDescriptor> configure) =>
 builder.AddDirectiveType(new DirectiveType(x =>
                                            configure(x.Name(name).Location(location))));
Exemple #2
0
 public static void RegisterDirective(
     this ISchemaConfiguration context,
     string name,
     DirectiveLocation location,
     Func <IDirectiveTypeDescriptor, IDirectiveTypeDescriptor> configure) =>
 context.RegisterDirective(new DirectiveType(x =>
                                             configure(x.Name(name).Location(location))));
Exemple #3
0
        private static bool TryLookupLocation(ISyntaxNode node, out DirectiveLoc location)
        {
            switch (node.Kind)
            {
            case NodeKind.Field:
                location = DirectiveLoc.Field;
                return(true);

            case NodeKind.FragmentDefinition:
                location = DirectiveLoc.FragmentDefinition;
                return(true);

            case NodeKind.FragmentSpread:
                location = DirectiveLoc.FragmentSpread;
                return(true);

            case NodeKind.InlineFragment:
                location = DirectiveLoc.InlineFragment;
                return(true);

            case NodeKind.VariableDefinition:
                location = DirectiveLoc.VariableDefinition;
                return(true);

            case NodeKind.OperationDefinition:
                switch (((OperationDefinitionNode)node).Operation)
                {
                case OperationType.Query:
                    location = Types.DirectiveLocation.Query;
                    return(true);

                case OperationType.Mutation:
                    location = Types.DirectiveLocation.Mutation;
                    return(true);

                case OperationType.Subscription:
                    location = Types.DirectiveLocation.Subscription;
                    return(true);

                default:
                    location = default;
                    return(false);
                }

            default:
                location = default;
                return(false);
            }
        }
 public static ISchemaBuilder AddDirectiveType(
     this ISchemaBuilder builder,
     string name,
     DirectiveLocation location) =>
 AddDirectiveType(builder, name, location, x => x);
Exemple #5
0
 public static void RegisterDirective(
     this ISchemaConfiguration context,
     string name,
     DirectiveLocation location) =>
 RegisterDirective(context, name, location, x => x);