Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created September 9, 2021 11:20
Show Gist options
  • Save percybolmer/64587fba25772242b8b2d54d3cffb6f5 to your computer and use it in GitHub Desktop.
Save percybolmer/64587fba25772242b8b2d54d3cffb6f5 to your computer and use it in GitHub Desktop.
graphql
// ResolveJobs is used to find all jobs related to a gopher
func (gs *GopherService) ResolveJobs(p graphql.ResolveParams) (interface{}, error) {
// Fetch Source Value
g, ok := p.Source.(Gopher)
if !ok {
return nil, errors.New("source was not a Gopher")
}
// Find Jobs Based on the Gophers ID
jobs, err := gs.jobs.GetJobs(g.ID)
if err != nil {
return nil, err
}
return jobs, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment