I am getting tired of adding last minute endpoints to our "REST" api. When functionality is constantly changing, and all the time I have is to just implement, the "REST" api starts to become a mess.
I'm thinking that with with graphql things should be a bit more organized, since there is really only mutations and queries.
But seeing the go libraries for graphql I'm not too sure if it's ready for production yet, or how convenient they are to develop in.
Has anyone been using Go with graphql in production? Whats your take on it?
Go is very important for us, but I'm beginning to think about gong back to, gasp, PHP or even try out Apollo's graphql server.
评论:
singular_pirate:
joefitzgerald:It's a shame someone grabbed the very search engine friendly
graphql-go/graphql
.https://github.com/neelance/graphql-go is very idiomatic and is actively developed. Go and GraphQL are a natural match, and this library leverages those strengths.
sh41:We're also using https://github.com/neelance/graphql-go and it's a great solution for us.
drink_with_me_to_day:For those who don't know, https://github.com/neelance is the main creator of GopherJS (https://github.com/gopherjs/gopherjs/graphs/contributors). He's actively working on graphql-go, so it's no surprise it's a great library.
saviorisdead:Nice, good to have more people in vouching for it. I had seen a comment about neelance's version, but it was over 3 months ago, and the repo looked a bit empty. I'll take another look.
kidovate:Disclaimer: we have GraphQL server built with https://github.com/graphql-go/graphql running in production for almost a year now and actively working on replacing it.
I will say that Go is bad fit for that task. Main reason is nature of GraphQL, it's just too much for Go's type system and in the end you forced to use
interface{}
everywhere. As a result of that code looks worse, it's hard to support and maintain. And don't forget about performance penalty ofinterface{}
. Better approach, in my opinion is to build GraphQL server in different programming language, with better support for that kind of task (JS and TypeScript or even Scala) and fetch required data via gRPC calls to Go-based services.
I'm sorry to say that you guys are not using the right approach. In Go the best way to do it is static code analysis with interfaces, funcs, and labeled fields filling your GraphQL schema.
Neelance and I both do it this way:
Go is most certainly suitable for Graphql especially with it's strong parallelism and concurrency. You're just not using the right library for the job.
thesnowmancometh:drink_with_me_to_day:Really glad I read these threads before starting to use
graphql-go/graphql
! I haven't seen these alternatives before.
nemith:Yeah, Go's type system is a big pain, even doing just normal REST.
It's unfortunate, because Go is just a great fit for us, and being able to compile and deploy a single binary is very attractive.
Go just doesn't fit the way you are used to. If you try to apply dynamic typed language ways to Go you will have a bad time.
