Last active
September 7, 2021 17:45
-
-
Save percybolmer/9580f68a05854efb91e66d5d8bcdf935 to your computer and use it in GitHub Desktop.
graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GopherService is the service that holds all repositories | |
type GopherService struct { | |
gophers Repository | |
} | |
// NewService is a factory that creates a new GopherService | |
func NewService(repo Repository) GopherService { | |
return GopherService{ | |
gophers: repo, | |
} | |
} | |
// ResolveGophers will be used to retrieve all available Gophers | |
func (gs GopherService) ResolveGophers(p graphql.ResolveParams) (interface{}, error) { | |
// Fetch gophers from the Repository | |
gophers, err := gs.gophers.GetGophers() | |
if err != nil { | |
return nil, err | |
} | |
return gophers, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment