99designs/gqlgen

Can I have a common resolver for multiple interface implementations?

Open

#3,725 opened on Jun 6, 2025

View on GitHub
 (1 comment) (1 reaction) (0 assignees)Go (1,250 forks)auto 404
help wanted

Repository metrics

Stars
 (10,737 stars)
PR merge metrics
 (PR metrics pending)

Description

I have a schema like this:

interface Result {
    title: String!
    description: String! @goField(forceResolver: true)
}

type Book implements Result {
    title: String!
    description: String! @goField(forceResolver: true)
    author: String!
    # ... other fields
}

type Article implements Result {
    title: String!
    description: String! @goField(forceResolver: true)
    section: String!
    # ... other fields
}

When I run the generator, it generates bookResolver and articleResolver, each one with its description field resolver. Is there a way I can generate a common resultResolver for them?

Contributor guide