<p>This might be a silly question but I have never used these technologies before. I wanted to know if there was a good library or service for creating a realtime app with GO and GraphQL. </p>
<p>If anyone has any experience with that and would like to share their advice, I would be very grateful. </p>
<p>Thanks</p>
<hr/>**评论:**<br/><br/>vektah: <pre><p>You should check out <a href="https://github.com/vektah/gqlgen#feature-comparison" rel="nofollow">https://github.com/vektah/gqlgen#feature-comparison</a> for a comparison of the top 4 libraries.</p>
<p>gqlgen works around go's lack of generics by using code generation. Take a look at <a href="https://gqlgen.com/getting-started/" rel="nofollow">https://gqlgen.com/getting-started/</a> </p>
<p>Disclaimer: author of gqlgen, may be a little biased.</p></pre>SeerUD: <pre><p>I think I've looked at your library before, and while impressive at getting things up and running quickly, it uses the neelance library (now <code>graph-gophers/graphql-go</code> I believe?).</p>
<p>Under the hood, this is still using a ton of reflection, so despite being able to generate a lot of nice looking strongly-typed code on the surface, it's still using a lot of reflection to figure out how to work with those types, right?</p>
<p>Interestingly, I did some benchmarks fairly recently and saw that <code>graphql-go/graphql</code> had taken the lead in terms of performance (at least for what I was testing it with).</p>
<p>Me and a friend have started our own GraphQL parser, and so far we're seeing really promising results. We've go the fastest lexer we've tested by quite a long way, and are moving onto the parser now. From there of course we'd still have the same issue as anything else doing GraphQL in Go - reflection of some kind. So, we plan on writing a code generator too, to generate the whole server with specific types in mind. It won't be a library like neelance's or the others, it will specifically make a server for your schema, and will actually be type safe, with no reflection - if we manage to pull it off. All in all, that should mean it's extremely fast too.</p></pre>lwcd: <pre><p>Afaik it's only using the parser from graph-gophers, looks like all the actual runtime code is without reflection. </p>
<p>I've not benchmaked it, but given it supports parallel execution of resolvers and doesn't rely on reflection, I'd be willing to bet it's pretty quick in most cases.</p></pre>lwcd: <pre><p>Is your parser available anywhere? I think there's a fair bit missing from the gophers parser atm. </p>
<p>It'd be nice to have a shared contract at the parser level so these projects could share some code etc</p></pre>SeerUD: <pre><p>Aha, I'll have to give this thing a proper looking at. Just tried the getting started tutorial but got some errors.</p></pre>vektah: <pre><p>That's a shame, I'll get it fixed. Unfortunately, because there is so much codegen involved godoc examples don't work so well. </p></pre>vektah: <pre><p>As lwcd suggests gqlgen doesn't use any runtime reflection at all. </p>
<p>If you take a look at the generated code it unrolls all of the field selection and json encoding.</p>
<p><a href="https://github.com/vektah/gqlgen/blob/master/example/todo/generated.go#L189-L219" rel="nofollow">https://github.com/vektah/gqlgen/blob/master/example/todo/generated.go#L189-L219</a></p>
<p>If you have some benchmarks somewhere I would love to add gqlgen to it, it should be stupid fast.</p></pre>mike_hman: <pre><p>GraphQL on Go, in general, is very rough due to limitations in the type system. As for realtime, I know less on that topic.</p>
<p>If you represent a company who is looking to deploy GraphQL, a better method for today is to spin up an Apollo or Vesper "proxy" as your API, which could even do authentication as well, then have it make requests to a Go backend via a more traditional protocol like REST or RPC.</p>
<p>If you're just a person looking to experiment, there are certainly GraphQL libraries for Go, but its a real pain. Another option is to use AWS AppSync, then write lambda function resolvers in Go. But otherwise: GraphQL is much more mature on Node, Rust, and Elixir. That's where a lot of the development is happening today. </p></pre>fakintheid: <pre><p>If you mean true real-time, golang isn’t gonna cut it. But for the “real time web” you could certainly use go with some web sockets and graph the points client side. </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传