The right way to handle and graphql endpoint

xuanbao · · 423 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m looking to see what options you guys are using and what&#39;s the right way for production to set up an endpoint for graphql. So far I was using something like this</p> <blockquote> <p>`http.HandleFunc(&#34;/graphql&#34;, func(w http.ResponseWriter, r *http.Request) { result, err := executor.Execute(context, r.URL.Query()[&#34;query&#34;][0], variables, &#34;&#34;)</p> <p>if err != nil { panic(err) } json.NewEncoder(w).Encode(result) })`</p> </blockquote> <p>It&#39;s not what really I was looking for, but it&#39;s working. If there&#39;s any handler that you&#39;re using guys would be nice to share it, ty :) Edit: I&#39;m using this goql library: <a href="https://github.com/playlyfe/go-graphql" rel="nofollow">https://github.com/playlyfe/go-graphql</a></p> <hr/>**评论:**<br/><br/>keithgrennan: <pre><p>I&#39;ve had success with this library: <a href="https://github.com/neelance/graphql-go" rel="nofollow">https://github.com/neelance/graphql-go</a> I quite like the design, they use reflection in a cool way - it results in some puzzling type errors at first but once i got the hang of it (the example they provide is essential) I found I&#39;m quite productive with it.</p></pre>valtjo: <pre><p>I agree! I tested <a href="https://github.com/graphql-go/graphql" rel="nofollow">https://github.com/graphql-go/graphql</a> and <a href="https://github.com/playlyfe/go-graphql" rel="nofollow">https://github.com/playlyfe/go-graphql</a> but IMHO neelance/graphql-go is the best.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

423 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传