-
Couldn't load subscription status.
- Fork 85
Closed
Milestone
Description
Right now fields are defined like:
typeBuilder.AddField("friends", u => u.Friends)
Or, with arguments, like:
typeBuilder
.AddField("friends", new { friendId = 0 },
args => (db, u) => u.Friends.Where(f => f.Id == args.friendId))
Adding a FieldBuilder would allow throwing more options on the fields without having a crazy method signature. Ideally, either of the current approaches would work to start the builder. Then users could add on other fluent calls to define security constraints, complexity, or additional optional arguments. Here's a hypothetical example of how a pretend astronaut in the distant future might use this:
typeBuilder
.AddField("friends", u => u.Friends) // if you used args here, those args would be *required*
.WithComplexity(10, 100) // we estimate a typical user will have between 10 and 100 friends
.WithArguments(new { id = 0 }, // optional filtering argument
args => (db, friends) => friends.Where(f => f.Id == args.id), 1) // modifies complexity to 1
.WithArguments(new { name = "" }, // optional filtering argument
args => (db, friends) => friends.Where(f => f.Name == args.name))
.WithSecurityFilter((db, friends) => friends.Where(f => idk(db, friends)) // filter query
.WithSecurityAssertion(fs => fs.All(SecurityManager.HasPermissionToView)) // in-memory predicate
Metadata
Metadata
Assignees
Labels
No labels