public TodoListMutation(TodoListData data)
        {
            Name = "Mutation";

            Field <ImportantType>(
                "createImportantTask",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ImportantTodoInputType> > {
                Name = "task"
            }
                    ),
                resolve: context =>
            {
                var importantTask = context.GetArgument <ImportantTodo>("task");
                return(data.AddImportantTodo(importantTask));
            });
        }
Esempio n. 2
0
        public TodoListQuery(TodoListData data)
        {
            Name = "Query";

            Field <ImportantType>(
                "important",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the important task."
            }
                    ),
                resolve: context => data.GetImportantTodoByIdAsync(context.GetArgument <string>("id"))
                );


            Field <ListGraphType <ImportantType> >(
                "importanttodos",
                resolve: context => data.GetPrimaryTodoAsync()
                );

            Func <ResolveFieldContext, string, object> func = (context, id) => data.GetSecondaryTodoByIdAsync(id);

            FieldDelegate <SecondaryType>(
                "secondary",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the secondary task"
            }
                    ),
                resolve: func
                );

            Field <ListGraphType <SecondaryType> >(
                "secondarytodos",
                resolve: context => data.GetSecondaryTodoAsync()
                );
        }