0

i have this Query :

 Field<UserTypes>
            (
                "user",
                arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>>
                { Name = "id" }),
                resolve: context =>
                {
                    var id = context.GetArgument<int>("id");
                    return userManager.FindByIdAsync(id.ToString());
                }
          );

but i need to pass multiple argument to this query . like username , name , lastname , . . .

how can i solve this problem ?

1 Answer 1

1

Remember that the parameter for QueryArguments is a params, so you can simply add as many as you like, seperated by commas like so:

 Field<UserTypes>
        (
            "user",
            arguments: new QueryArguments
            (
               new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" },
               new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "username" },
               new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "name" },
               new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "lastname" }
            ),
            resolve: context =>
            {
                var id = context.GetArgument<int>("id");
                return userManager.FindByIdAsync(id.ToString());
            }
      );

Hope this helps you!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.