Allow defining type resolvers also for interface fields
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
What problem does this feature proposal attempt to solve?
When defining types that implement an interface is very verbose having to specify the resolver on each of the type fields when using a custom resolver. Look at this example:
# User interface
interface User {
accountType: AccountType! @rename(attribute: "account_type")
id: UserId!
name: String!
url(lang: String!): String!
}
# UserGroup type
type UserGroup implements User {
accountType: AccountType! @rename(attribute: "account_type")
id: UserId!
name: String!
url(lang: String!): String! @field(resolver: "App\\GraphQL\\Types\\User\\Url")
}
# UserPersonal type
type UserPersonal implements User {
accountType: AccountType! @rename(attribute: "account_type")
id: UserId!
name: String!
url(lang: String!): String! @field(resolver: "App\\GraphQL\\Types\\User\\Url")
firstName: String! @rename(attribute: "first_name")
lastName: String! @rename(attribute: "last_name")
}
That @field directive in the types is repetitive and ugly, because is not even possible to use a short form like User\\Url.
Which possible solutions should be considered?
Would be good if this would be automatically inferred, avoiding the need to use the @field directive. In the example, the custom resolver is placed in Types\User\Url, denoting that the resolver is common to any type implementing User.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The proposal names GraphQL interface fields, implementing types, the @field directive, and the custom resolver Types\User\Url, but no files or tests. Start by locating the existing @field and interface-resolution behavior, then define the expected resolver inference and add coverage showing that implementing types no longer repeat the directive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, laravel, php
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100