<p>Go is my favorite language by far. I'm building a project to learn new things , it's a graphql proxy, and i'm in doubt if Go is the best choice or not.</p>
<p>The proxy gonna receive a unknow graphql query and do some processing behind the scenes with the response from origin. The problem is that the query isn't something mapped, it's very dynamic and i'm having lot's of trouble to do a parser with Go type system. I'm trying to avoid the max i can the use of interface{}, but i can't figure a way to do the parser into structures without this. Don't know if reflect and unsafe could be used to do this. </p>
<p>Whould this project be better with a dynamic language like Elixir or even Javascript?</p>
<hr/>**评论:**<br/><br/>gopherinhole: <pre><p>I'm a little confused, from what I understand of GraphQL, queries always follow a predefined schema, so I'm not sure how they could be 'very dynamic'. I have used a graphql server lib for Golang and it was a good experience.</p>
<p>If you're having to use reflect and unsafe, or lots of interface{}, chances are you need to reconsider your architecture, not your programming language.</p></pre>pernuts: <pre><p>My idea is to build a proxy. The server receive a request to add a graphql endpoint, after this, the server do a introspection on the endpoint to get the schema (this is the hard part) and after this, the server is ready to receive requests. </p>
<p>When a graphql user query get in, the server know how to cache, validate the query, generate metrics, etc... All at run time, the schema isn't pre defined like a standart graphql server.</p></pre>epiris: <pre><p>Go can do dynamic things like any other language, only your concepts need to be concrete. A struggle here makes me think your design is not flushed out, have you written anything up? If not you should start with 2-3 high level user requests and map them to a bullet list of features they should be able to do. Then find what is common between them and begin flushing out your design in concrete types. </p>
<p>Point is a static type system does not have a unsolvable problem, so if you want to use Go, you should :)</p></pre>tv64738: <pre><p>Why a proxy? That all sounds like things a GraphQL server should do.</p></pre>pernuts: <pre><p>It's more a gateway, gonna have authentication, cache, rate control, etc... So the origin graphql server don't need to implement all this features. </p>
<p>Graphql is known to play bad with the http ecosystem, like cdns, the idea of this proxy/gateway is to abstract/solve this problem to the graphql implementations.</p></pre>tv64738: <pre><p>That still sounds like something that belongs in the GraphQL server...</p></pre>dedalqq: <pre><p>What do you think is critical?</p>
<p>If you do not rest on speed and at the same time it is important that the code is easily supported and understandable, then it makes sense to write in the language in which the code will be understandable.</p></pre>SeerUD: <pre><p>Are you using a GraphQL library for Go? As someone else has said, you should have a schema, right?</p></pre>kromem: <pre><p>There are a number of graphql libraries for mapping your schema. Personally I like the neelance library. Will make your life much easier.</p></pre>shark1337: <pre><p>I did experienced graphql with go and I was very satisfied about it. Go provides an graphql implementation 10 times faster than the javascript one and it's also production ready. (playlyfe/graphql). You won't regret going with go ;)</p></pre>throwawayguy123xd: <pre><p>yea if ur just doing string parsing use another lang like php or javascript, i think go is a little annoying to write for something that simple, because of all the terseness of string.foo() and rune.bar(), and interfaces{} like you said. (perl is best: <code>matches =~ /regex/</code>)</p>
<p>for proxying though go is a perfect language for these high-speed apps like middleware and servers.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传