99designs/gqlgen

Can I have a common resolver for multiple interface implementations?

Aperta

#3725 aperta il 6 giu 2025

 (1 commento) (1 reazione) (0 assegnatari)Go (1250 fork)auto 404
help wanted

Metriche repository

Star
 (10.737 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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?

Guida contributor