Last active
September 10, 2021 10:03
-
-
Save percybolmer/309878780d0f6ac8c92ea70d1fac93f7 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
// 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") | |
} | |
// Here we extract the Argument Company | |
company := "" | |
if value, ok := p.Args["company"]; ok { | |
company, ok = value.(string) | |
if !ok { | |
return nil, errors.New("id has to be a string") | |
} | |
} | |
// Find Jobs Based on the Gophers ID | |
jobs, err := gs.jobs.GetJobs(g.ID, company) | |
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