Skip to content

Instantly share code, notes, and snippets.

@VictorKabata
Last active October 29, 2022 17:20
Show Gist options
  • Save VictorKabata/ebb538d05fc5a7647d78eb3e3579f609 to your computer and use it in GitHub Desktop.
Save VictorKabata/ebb538d05fc5a7647d78eb3e3579f609 to your computer and use it in GitHub Desktop.
...
"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