Пример #1
0
            public BusDetailsMutation() : base(name: BusDetailsMutationName, description: BusDetailsMutationDescription)
            {
                var detailsArgument = new QueryArgument <NonNullGraphType <BusDetailsInput> >
                {
                    Name        = DetailsParameterName,
                    Description = DetailsParameterDescription
                };

                Arguments = new GraphQL.Types.QueryArguments(new QueryArgument[] { detailsArgument });
            }
Пример #2
0
 public static GraphQL.Types.QueryArguments GetIdLookupArguments()
 {
     GraphQL.Types.QueryArguments arguments = new GraphQL.Types.QueryArguments(new QueryArgument[]
     {
         new QueryArgument <StringGraphType>
         {
             Name        = ApiConstants.GraphqlArgumentNames.ITEMID,
             Description = "The item ID"
         }
     });
     return(arguments);
 }
Пример #3
0
 public static GraphQL.Types.QueryArguments SwitchCommandArgument()
 {
     GraphQL.Types.QueryArguments arguments = new GraphQL.Types.QueryArguments(new QueryArgument[]
     {
         new QueryArgument <StringGraphType>
         {
             Name        = ApiConstants.GraphqlArgumentNames.GET,
             Description = "The get command is sent when we want this query to lookup a value relating to the action."
         }, new QueryArgument <StringGraphType>
         {
             Name        = ApiConstants.GraphqlArgumentNames.PUT,
             Description = "The put command is sent to make the query perform an action."
         }
     });
     return(arguments);
 }
Пример #4
0
 public static GraphQL.Types.QueryArguments GetItemLookupArguments()
 {
     GraphQL.Types.QueryArguments arguments = new GraphQL.Types.QueryArguments(new QueryArgument[]
     {
         new QueryArgument <StringGraphType>
         {
             Name        = ApiConstants.GraphqlArgumentNames.ITEMID,
             Description = "The sitecore item ID"
         }, new QueryArgument <StringGraphType>
         {
             Name        = ApiConstants.GraphqlArgumentNames.PATH,
             Description = "The Sitecore route, that matches the item name"
         }
     });
     return(arguments);
 }
Пример #5
0
 public FieldType Field <TGraphType>(
     string name,
     string description       = null,
     QueryArguments arguments = null,
     Func <ResolveFieldContext <TSourceType>, object> resolve = null,
     string deprecationReason = null)
     where TGraphType : IGraphType
 {
     return(AddField(new FieldType
     {
         Name = name,
         Description = description,
         DeprecationReason = deprecationReason,
         Type = typeof(TGraphType),
         Arguments = arguments,
         Resolver = resolve != null
             ? new FuncFieldResolver <TSourceType, object>(resolve)
             : null,
     }));
 }
Пример #6
0
 public FieldType FieldDelegate <TGraphType>(
     string name,
     string description       = null,
     QueryArguments arguments = null,
     Delegate resolve         = null,
     string deprecationReason = null)
     where TGraphType : IGraphType
 {
     return(AddField(new FieldType
     {
         Name = name,
         Description = description,
         DeprecationReason = deprecationReason,
         Type = typeof(TGraphType),
         Arguments = arguments,
         Resolver = resolve != null
             ? new DelegateFieldModelBinderResolver(resolve)
             : null,
     }));
 }
Пример #7
0
 /// <summary>
 /// Adds a field with the specified properties to this graph type.
 /// </summary>
 /// <param name="type">The .NET type of the graph type of this field.</param>
 /// <param name="name">The name of the field.</param>
 /// <param name="description">The description of the field.</param>
 /// <param name="arguments">A list of arguments for the field.</param>
 /// <param name="resolve">A field resolver delegate. Only applicable to fields of output graph types. If not specified, <see cref="NameFieldResolver"/> will be used.</param>
 /// <param name="deprecationReason">The deprecation reason for the field. Applicable only for output graph types.</param>
 /// <returns>The newly added <see cref="FieldType"/> instance.</returns>
 public FieldType FieldAsync(
     Type type,
     string name,
     string description       = null,
     QueryArguments arguments = null,
     Func <IResolveFieldContext <TSourceType>, Task <object> > resolve = null,
     string deprecationReason = null)
 {
     return(AddField(new FieldType
     {
         Name = name,
         Description = description,
         DeprecationReason = deprecationReason,
         Type = type,
         Arguments = arguments,
         Resolver = resolve != null
             ? new AsyncFieldResolver <TSourceType, object>(resolve)
             : null
     }));
 }
Пример #8
0
        public void Field <TType>(
            string name,
            string description       = null,
            QueryArguments arguments = null,
            Func <ResolveFieldContext, object> resolve = null)
            where TType : GraphType
        {
            if (_fields.Exists(x => x.Name == name))
            {
                throw new ArgumentOutOfRangeException("name", "A field with that name is already registered.");
            }

            _fields.Add(new FieldType
            {
                Name      = name,
                Type      = typeof(TType),
                Arguments = arguments,
                Resolve   = resolve
            });
        }
Пример #9
0
        /// <summary>
        /// Adds a field with the specified properties to a specified output graph type.
        /// </summary>
        /// <param name="obj">The graph type to add a field to.</param>
        /// <param name="name">The name of the field.</param>
        /// <param name="type">The graph type of this field.</param>
        /// <param name="description">The description of the field.</param>
        /// <param name="arguments">A list of arguments for the field.</param>
        /// <param name="resolve">A field resolver delegate. If not specified, <see cref="NameFieldResolver"/> will be used.</param>
        public static void FieldAsync( //TODO: v5 - change void to T where T : IObjectGraphType
            this IObjectGraphType obj,
            string name,
            IGraphType type,
            string description       = null,
            QueryArguments arguments = null,
            Func <IResolveFieldContext, Task <object> > resolve = null)
        {
            var field = new FieldType
            {
                Name         = name,
                Description  = description,
                Arguments    = arguments,
                ResolvedType = type,
                Resolver     = resolve != null
                    ? new AsyncFieldResolver <object>(resolve)
                    : null
            };

            obj.AddField(field);
        }
Пример #10
0
 public FieldType FieldSubscribeAsync <TGraphType>(
     string name,
     string description       = null,
     QueryArguments arguments = null,
     Func <IResolveFieldContext <TSourceType>, object> resolve = null,
     Func <IResolveEventStreamContext, Task <IObservable <object> > > subscribeAsync = null,
     string deprecationReason = null)
     where TGraphType : IGraphType
 {
     return(AddField(new EventStreamFieldType
     {
         Name = name,
         Description = description,
         DeprecationReason = deprecationReason,
         Type = typeof(TGraphType),
         Arguments = arguments,
         Resolver = resolve != null
             ? new FuncFieldResolver <TSourceType, object>(resolve)
             : null,
         AsyncSubscriber = subscribeAsync != null
             ? new AsyncEventStreamResolver <object>(subscribeAsync)
             : null
     }));
 }