gqlgen-example icon indicating copy to clipboard operation
gqlgen-example copied to clipboard

Question: adding new resolvers/services?

Open jmandel1027 opened this issue 5 years ago • 1 comments

Hey there!

Thanks for this sample, really nice and simple, one question though, how can new services be added to the NewResolver method? https://github.com/alexzimmer96/gqlgen-example/blob/e63752d46e2a7d37e9bd10058e6c3178aed12679/graphql/resolvers.go#L13

it looks like only a single service, in this case articleService passed through, would changing this block to the following do the trick? I'm still new to go but quite familiar with building gql backends with apollo.

type Resolver struct {
	articleService service.IArticleService,
        someServiceA service.ISomeServiceA,
        someServiceB service.ISomeServiceB,
}


func NewResolver() *Resolver {
	return &Resolver{
		articleService: service.IArticleService,
                someServiceA: service.ISomeServiceA,
                someServiceB: service.ISomeServiceB,
	}
}

Anyway thanks for providing this example

jmandel1027 avatar Aug 10 '19 18:08 jmandel1027

Hi @jay-manday Wow.. I took me more than one year to realize there's actually a Issue in one of my projects. I apol(l)ogize for the late feedback. At least with the version i've used, this should do the trick.

alexzimmer96 avatar Dec 14 '20 09:12 alexzimmer96