コード例 #1
0
 protected override void Configure(
     IObjectTypeDescriptor <Person> descriptor)
 {
     descriptor.Directive(new Resolve());
     descriptor.Directive(new ADirective {
         Append = "Foo"
     });
     descriptor.Field(t => t.Name)
     .Directive(new BDirective {
         Append = "Bar"
     });
 }
コード例 #2
0
        public static IObjectTypeDescriptor <T> Authorize <T>(
            this IObjectTypeDescriptor <T> descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            return(descriptor.Directive(new AuthorizeDirective()));
        }
コード例 #3
0
        public static IObjectTypeDescriptor Authorize(
            this IObjectTypeDescriptor self)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            return(self.Directive(new AuthorizeDirective()));
        }
コード例 #4
0
    public static IObjectTypeDescriptor Authorize(
        this IObjectTypeDescriptor descriptor,
        params string[] roles)
    {
        if (descriptor == null)
        {
            throw new ArgumentNullException(nameof(descriptor));
        }

        return(descriptor.Directive(new AuthorizeDirective(roles)));
    }
コード例 #5
0
    public static IObjectTypeDescriptor <T> Authorize <T>(
        this IObjectTypeDescriptor <T> descriptor,
        ApplyPolicy apply = ApplyPolicy.BeforeResolver)
    {
        if (descriptor == null)
        {
            throw new ArgumentNullException(nameof(descriptor));
        }

        return(descriptor.Directive(new AuthorizeDirective(apply: apply)));
    }
コード例 #6
0
        public static IObjectTypeDescriptor <T> Authorize <T>(
            this IObjectTypeDescriptor <T> self,
            string policy)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            return(self.Directive(new AuthorizeDirective(policy)));
        }
コード例 #7
0
        public static IObjectTypeDescriptor Authorize(
            this IObjectTypeDescriptor self,
            string policy,
            params string[] roles)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            return(self.Directive(new AuthorizeDirective(policy, roles)));
        }
コード例 #8
0
        /// <summary>
        /// Adds the @key directive which is used to indicate a combination of fields that
        /// can be used to uniquely identify and fetch an object or interface.
        /// <example>
        /// type Product @key(fields: "upc") {
        ///   upc: UPC!
        ///   name: String
        /// }
        /// </example>
        /// </summary>
        /// <param name="descriptor">
        /// The object type descriptor on which this directive shall be annotated.
        /// </param>
        /// <param name="fieldSet">
        /// The field set that describes the key.
        /// Grammatically, a field set is a selection set minus the braces.
        /// </param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="descriptor"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="fieldSet"/> is <c>null</c> or <see cref="string.Empty"/>.
        /// </exception>
        public static IObjectTypeDescriptor Key(
            this IObjectTypeDescriptor descriptor,
            string fieldSet)
        {
            if (descriptor is null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (string.IsNullOrEmpty(fieldSet))
            {
                throw new ArgumentException(
                          FieldDescriptorExtensions_Key_FieldSet_CannotBeNullOrEmpty,
                          nameof(fieldSet));
            }

            return(descriptor.Directive(
                       WellKnownTypeNames.Key,
                       new ArgumentNode(
                           WellKnownArgumentNames.Fields,
                           new StringValueNode(fieldSet))));
        }
コード例 #9
0
ファイル: QueryType.cs プロジェクト: tsmojver/hotchocolate
 protected override void Configure(
     IObjectTypeDescriptor <Query> descriptor)
 {
     descriptor.Directive("executeValidation");
     descriptor.Field(t => t.SayHello(default))