Last active
October 29, 2022 17:20
-
-
Save VictorKabata/ebb538d05fc5a7647d78eb3e3579f609 to your computer and use it in GitHub Desktop.
This file contains 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
... | |
"note": &graphql.Field{ | |
Name: "Get note by ID", | |
Type: noteType, | |
Description: "Get note by ID", | |
Args: graphql.FieldConfigArgument{"id": &graphql.ArgumentConfig{Type: graphql.Int}}, | |
Resolve: func(params graphql.ResolveParams) (interface{}, error) { | |
id, isValid := params.Args["id"].(int) | |
if isValid { | |
for _, note := range notes { | |
if note.ID == id { | |
return note, nil | |
} | |
} | |
} | |
return nil, nil | |
}, | |
}, // Additional fields | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment