GraphQL servers in golang
Follow the steps below to use this service
- Copy dapr bindings spec files
$ cp ./dapr/bindings/components/jsonbinding.yaml $HOME/.dapr/components/jsonbinding.yaml
$ cp ./dapr/bindings/components/graphql.yaml $HOME/.dapr/components/graphql.yaml
- Run the API Graphql service alongside a Dapr sidecar
$ make run
- Prepare Data
$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation {\n createTodo {\n id\n }\n}","variables":{}}'
More help to get started gqlgen
If you think you've found a bug, or something isn't behaving the way you think it should, please raise an issue on GitHub.
type Post {
id: Int!
title: String!
body: String!
url: String!
type: String!
userId: Int!
createdAt: String!
comments: [Comment]
}
type Comment {
id: Int!
name: String!
email: String!
body: String!
postId: Int!
createdAt: String!
}
type Geo {
lat: String!
lng: String!
}
type Address {
street: String!
suite: String!
city: String!
zipcode: String!
geo: Geo!
}
type Company {
name: String!
catchPhrase: String!
bs: String!
}
type User {
id: Int!
name: String!
username: String!
email: String!
photo: String!
website: String!
createdAt: String!
address: Address!
company: Company!
posts: [Post]
}
type Todo {
id: Int!
title: String!
completed: Boolean!
user: User!
}
- posts:
[Post!]!
- comments:
[Comment!]!
- todos:
[Todo!]!
- users:
[User!]!
- user(id: Int!):
User!
- post(id: Int!):
Post!
- comment(id: Int!):
Comment!
- getInfoByUserId(id: Int!):
User!
- getPostsByUserId(id: Int!, postType: String!):
[Post!]!
- getCommentsByPostId(id: Int!):
[Comment!]!
- createTodo:
[Todo!]!
Examples: misc/urth.postman_collection.json
$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n posts {\n id\n title\n body\n url\n type\n userId\n createdAt\n }\n}","variables":{}}'
$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n comments {\n id\n name\n email\n body\n postId\n createdAt\n }\n}","variables":{}}'
$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n users {\n id\n name\n username\n email\n photo\n website\n address {\n street\n suite\n city\n zipcode\n geo {\n lat\n lng\n }\n }\n company {\n name\n catchPhrase\n bs\n }\n createdAt\n }\n}","variables":{}}'
Check the LICENSE file for details