Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Query Argument Syntax #27

Open
Michannne opened this issue Jun 3, 2019 · 0 comments
Open

Simplify Query Argument Syntax #27

Michannne opened this issue Jun 3, 2019 · 0 comments

Comments

@Michannne
Copy link
Owner

Is your feature request related to a problem? Please describe.
Current query arg syntax is unwiedly, and involves the use of an extension method to convert a C# type into a graph type. Yes, it should be up to the user to supply the correct graph-type, but there should be an easier way so user does not have to think too much of the type or conversions before passing it in.

Describe the solution you'd like
Something simple, and easy for the user without giving up their control of the type being passed, but without conversion, such as:

services.AddGraphQL()
.Query<Author>(
    () => new Query()
    {
        Expression = "author",
        Args = new ArgList() {
			["authorId"] = (long authorId) => {
				DefaultValue = 0,
				Description = "The Author to be searched"
			},
			["bookId"] = (long bookId) => {
				DefaultValue = 0,
				Description = "The Book to be searched"
			},
			["bookName"] = (string bookName) => {
				DefaultValue = null,
				Description = "The name of the Book to be searched"
			},
		},
        Resolver = (context) => authorRepo.GetAll().Where(a => a.AuthorId == (long)context.Arguments["authorId"])
    })
.Build()

Describe alternatives you've considered
Improving the conversion syntax may also be helpful, but the real solution I feel is change how the arguments are added, in GraphQL.NET is equally painful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant