go-graphql query, mutation issues
See original GitHub issueHey all. After installing successfully the go-graphql example, opening http://localhost:4000 playground i try to create a new “draft”:
mutation { createDraft(title:"Test title",content:"Test content",authorEmail:"podinacristi@gmail.com"){ id title content } }
i got the following error in go:
`interface conversion: interface {} is nil, not map[string]interface {}
goroutine 22 [running]: runtime/debug.Stack(0x1, 0x0, 0x0) /usr/local/go/src/runtime/debug/stack.go:24 +0xa7 runtime/debug.PrintStack() /usr/local/go/src/runtime/debug/stack.go:16 +0x22 go-graphql/vendor/github.com/99designs/gqlgen/graphql.DefaultRecover(0x8f02c0, 0xc000213f20, 0x806300, 0xc0001209f0, 0xc000136d90, 0x40d23f) /home/dan/go/src/go-graphql/vendor/github.com/99designs/gqlgen/graphql/recovery.go:16 +0xa7 main.(*executionContext).FieldMiddleware.func1(0xc000368bb0, 0x8f02c0, 0xc000213f20, 0xc000137900) /home/dan/go/src/go-graphql/server/generated.go:2461 +0x78 panic(0x806300, 0xc0001209f0) /usr/local/go/src/runtime/panic.go:513 +0x1b9 go-graphql/vendor/github.com/prisma/prisma-examples/go-graphql/prisma-client.PostExec.Exec(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0003dc7e0, 0x1, 0x1, 0x0, …) /home/dan/go/src/go-graphql/vendor/github.com/prisma/prisma-examples/go-graphql/prisma-client/prisma.go:2887 +0x14cf main.(*mutationResolver).CreateDraft(0xc0001620a0, 0x8f02c0, 0xc000213f20, 0xc0002a6021, 0xa, 0xc0002a6038, 0xc, 0xc0002a6055, 0x16, 0x0, …) /home/dan/go/src/go-graphql/server/resolver.go:36 +0x5d2 main.(*executionContext)._Mutation_createDraft.func1(0x8f02c0, 0xc000213f20, 0xc000198030, 0xc000209898, 0x20, 0xc000209890) /home/dan/go/src/go-graphql/server/generated.go:464 +0x232 go-graphql/vendor/github.com/99designs/gqlgen/graphql.DefaultResolverMiddleware(0x8f02c0, 0xc000213f20, 0xc000507720, 0x8f02c0, 0xc000213f20, 0xc000209900, 0xc000507720) /home/dan/go/src/go-graphql/vendor/github.com/99designs/gqlgen/graphql/context.go:33 +0x3a main.(*executionContext).FieldMiddleware(0xc000368bb0, 0x8f02c0, 0xc000213f20, 0x0, 0x0, 0xc000507720, 0x0, 0x0) /home/dan/go/src/go-graphql/server/generated.go:2465 +0xa1 main.(*executionContext)._Mutation_createDraft(0xc000368bb0, 0x8f02c0, 0xc000213f20, 0xc00012c800, 0xc000213e30, 0x3, 0x3, 0x1, 0xc000507700) /home/dan/go/src/go-graphql/server/generated.go:463 +0x1b2 main.(*executionContext)._Mutation(0xc000368bb0, 0x8f02c0, 0xc000213e60, 0xc000368800, 0x1, 0x1, 0x7f891d9706c0, 0x0) /home/dan/go/src/go-graphql/server/generated.go:430 +0x589 main.(*executableSchema).Mutation.func1(0x8f02c0, 0xc000213e00, 0x8272c0, 0x80d801, 0xc0005076e0) /home/dan/go/src/go-graphql/server/generated.go:390 +0x61 go-graphql/vendor/github.com/99designs/gqlgen/graphql.DefaultRequestMiddleware(0x8f02c0, 0xc000213e00, 0xc0005076e0, 0xc000142c40, 0xc000209be0, 0x42b072) /home/dan/go/src/go-graphql/vendor/github.com/99designs/gqlgen/graphql/context.go:41 +0x3a main.(*executableSchema).Mutation(0xc000150000, 0x8f02c0, 0xc000213e00, 0xc0003dc700, 0xc000213e00) /home/dan/go/src/go-graphql/server/generated.go:389 +0xd8 go-graphql/vendor/github.com/99designs/gqlgen/handler.GraphQL.func1(0x8efec0, 0xc00048e2a0, 0xc000140c00) /home/dan/go/src/go-graphql/vendor/github.com/99designs/gqlgen/handler/graphql.go:255 +0x562 net/http.HandlerFunc.ServeHTTP(0xc000119110, 0x8efec0, 0xc00048e2a0, 0xc000140c00) /usr/local/go/src/net/http/server.go:1964 +0x44 net/http.(*ServeMux).ServeHTTP(0xbb6140, 0x8efec0, 0xc00048e2a0, 0xc000140c00) /usr/local/go/src/net/http/server.go:2361 +0x127 net/http.serverHandler.ServeHTTP(0xc0001284e0, 0x8efec0, 0xc00048e2a0, 0xc000140c00) /usr/local/go/src/net/http/server.go:2741 +0xab net/http.(*conn).serve(0xc000150280, 0x8f0200, 0xc0001427c0) /usr/local/go/src/net/http/server.go:1847 +0x646 created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2851 +0x2f5 ` I thought that the fact that the user email did not exist, so i went to my prisma endpoint and create a user with that email successfully, and also create a test draft in the same prisma endpoint. Querying the playground for the draft gave me an empty response:
`{ drafts{ id title } }
{ “data”: { “drafts”: [] } } ` I have go 1.11 installed, prisma 1.17 and latest graph-cli
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
I can try to explain it better first 😃 resolver.go, generated.go and server.go is importing “github.com/prisma/prisma-examples/go-graphql/prisma-client”, which points to “https://eu1.prisma.sh/demo/go-graphql/dev”, that way you cannot set your own endpoint. Making it a local package like “go-graphql/prisma-client” gives you control to setup the endpoint with your own at prisma deploy
Hey @podinacristi, this should have been solved by the latest refactoring and cleanup effort of the examples. Please try the example again by following the steps in the README. If you’re still running into the same problem, please reopen this issue! 🙏