Last active
September 9, 2021 05:26
-
-
Save percybolmer/550c3a4014f0a584cae84ac037c21351 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
func main() { | |
// Create the Gopher Repository | |
gopherService := gopher.NewService(gopher.NewMemoryRepository()) | |
// We create yet another Fields map, one which holds all the different queries | |
fields := graphql.Fields{ | |
// We define the Gophers query | |
"gophers": &graphql.Field{ | |
// It will return a list of GopherTypes, a List is an Slice | |
// We defined our Type in the Schemas package earlier | |
Type: graphql.NewList(schemas.GopherType), | |
// We change the Resolver to use the gopherRepo instead, allowing us to access all Gophers | |
Resolve: gopherRepo.ResolveGophers, | |
// Description explains the field | |
Description: "Query all Gophers", | |
}, | |
} | |
........ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment