Michannne / Michannne/graphql-core

Simplify Query Argument Syntax

Open
#27 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10
Forks
3
PR merge metrics
No merged PRs in 30d

Description

**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:

```csharp
services.AddGraphQL()
.Query(
() => 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

Contributor guide

Open the contributing guide

Research direction

Start by locating the Query configuration, ArgList, Args, and Resolver APIs shown in the issue, then compare how current C# types are converted to GraphQL argument types. Define and implement a simpler argument declaration that preserves explicit type control, and verify that defaults, descriptions, and resolver access still work as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.