-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Create basic example follow http://graphql.org/docs/getting-started/ #21
Conversation
Thanks for sharing your time to contribute this PR 👍🏻 I think thats a great idea having more examples that others can use to draw parallels with the official docs. /cc: @chris-ramon: What do you think? |
Thanks a lot @thanhliem89dn! 🌟 I've tried locally and Test with Get: http://localhost:8080/graphql?query={user(id:%221%22){name}} Test with Post: curl -XPOST http://localhost:8080/graphql -H 'Content-Type: application/graphql' -d 'query Root{ user(id:'1'){name} }' {
"data": {
"user": null
}
} Also it think we might want to pluralize |
Thanks for your time to take a look on this pull request. Replace '1' in [curl -XPOST http://localhost:8080/graphql -H 'Content-Type: application/graphql' -d 'query Root{ user(id:'1'){name} }'] with "1" It'll be ok :). And I also fixed curl command in example in new commit beside changed example to examples. |
Great! 🌟 - thanks for updates @thanhliem89dn Just tried and both test are working as expected: Test with Get: http://localhost:8080/graphql?query={user(id:%221%22){name}} curl -XPOST http://localhost:8080/graphql -H 'Content-Type: application/graphql' -d 'query Root{ user(id:"1"){name} }' {
"data": {
"user": {
"name": "Dan"
}
}
} Also just for consistency could we use curl -g "http://localhost:8080/graphql?query={user(id:%221%22){name}}"
Finally what do you think if we go for snake case naming so cc/ @sogko |
In my opinion, I think camelCase is better snake_case. About rename simpleUserGraph.go -> main.go, It's a good idea :) |
Alright, thanks @thanhliem89dn, I think we are close to merging this one, we could do the following:
$GOPATH/bin/goimports -d simpleUserGraph.go diff simpleUserGraph.go gofmt/simpleUserGraph.go
--- /var/folders/v7/ssjjclsd4ng3l03hjpk19fs80000gn/T/gofmt350536176 2015-10-19 15:27:13.000000000 -0300
+++ /var/folders/v7/ssjjclsd4ng3l03hjpk19fs80000gn/T/gofmt848666255 2015-10-19 15:27:13.000000000 -0300
@@ -3,10 +3,11 @@
import (
"encoding/json"
"fmt"
- "github.com/chris-ramon/graphql-go/types"
- "github.com/sogko/graphql-go-handler"
"io/ioutil"
"net/http"
+
+ "github.com/chris-ramon/graphql-go/types"
+ "github.com/sogko/graphql-go-handler"
)
/* Finally I think we could rename cc/ @sogko |
-Rename SimpleUserGraph to http -Goimports
Can't agree more with you. I have changed all of them. Please take a look @chris-ramon @sogko |
Great! thanks @thanhliem89dn 🌟 - to keep consistency could we use go run main.go
Now server is running on port 8080
Test with Post: curl -XPOST http://localhost:8080/graphql -H 'Content-Type: application/graphql' -d 'query Root{ user(id:"1"){name} }'
Test with Get: curl -g "http://localhost:8080/graphql?query={user(id:%221%22){name}}" |
Thanks for spending time to contribute this @thanhliem89dn, this looks great! |
thank for your time @chris-ramon, I have just edited curl command for Get example. I think it's nice. One more thing, Why don't We open a git room for communicate :) |
Alright, thanks again @thanhliem89dn! - yes! good idea to have a chat room, I think we could start by using gitter, here the PR. I would like to share my final thoughts about this, merging this PR will make Perhaps this example should be on Other solution could be merge both projects handler := gql.NewHandler() Please do share your thoughts about this one, thanks! 👍 |
Thanks for your time to reply, But I think We shouldn't merge both projects [graphql-go] and [graphql-go-handler]. In my point of view, We almost use http handler but use my own, so keep [graphql-go] separate to [graphql-go-handler] or [relay] is better. So We can use it in any purpose also implement in any old project. About my example I think It's a very first look for everyone to interact with [graphql-go] as GraphQL official document. But As you told It used [graphql-go-handler] to handle request so I think it's better if I take [graphql-go-handler] away. |
Alright, yeah I agree @thanhliem89dn, perhaps we should preserve
|
Hi @chris-ramon, I have just taken [graphql-go-handler] out of example and just use net/http. I think it's clear for anyone to start with this RP. |
Thanks for the updates @thanhliem89dn ! - I've tested locally and is working great, I think is ready to go. /cc: @sogko |
I've just tested it on my local machine as well, looks great! Thanks @thanhliem89dn! Looking forward to more contributions from you 👍🏻 |
Create basic example follow http://graphql.org/docs/getting-started/
Alternative concurrent evaluation of fields
… from here for perf-related PRs. - simple hello world equivalent - with a list - deeper query with list - query with many root fields and list in each of them - deeper query with many root fields and lists To really bring out probable issues with query perf, a latency is introduced to the data retrieval (previously it was just in-memory data fetch) When testing against branch before PR #20 and #21, this really highlighted the problem with evaluating list fields. In the future, more benchmarks for queries with fragments probably would be useful.
How do you parse a schema? In the node version you pass a string and get a schema object that you can then initialize as a middleware? |
Just port a simple example from JS into GoLang follow http://graphql.org/docs/getting-started/
I hope it will make everyone easy to start to learn about Graphql by using graphql-go and understand how to port js schema sources into Golang