Пример #1
0
 public MySubscription(IMyInputSubjectHelper subjectHelper)
 {
     Name        = "Subscription";
     Description = "Subscribe to new myInput mutations";
     AddField(new EventStreamFieldType
     {
         Name        = "myInputMutationReceived",
         Description = "A MyInput mutation was received",
         Type        = typeof(MyInputRecievedMessageType),
         Resolver    = new FuncFieldResolver <MyInputReceivedMessage>(x => x.Source as MyInputReceivedMessage),
         Subscriber  = new  EventStreamResolver <MyInputReceivedMessage>(x => subjectHelper.GetInput()),
     });
 }
Пример #2
0
        public MyMutation(IMyInputSubjectHelper subjectHelper)
        {
            Field <BooleanGraphType>(
                "createInput",
                "create a new input, to trigger subscription",
                new QueryArguments(new QueryArgument <NonNullGraphType <MyInputType> >
            {
                Name = "myInputType"
            }), context =>
            {
                // trigger subscription notify
                var myInputMessage = context.GetArgument <MyInputReceivedMessage>("myInputType");

                subjectHelper.AddNew(myInputMessage);
                return(true);
            });
        }