Readme changes

This commit is contained in:
Matthieu Lamalle 2019-07-24 17:29:11 +02:00
parent cea33e9d36
commit 73fac765de
4 changed files with 30 additions and 2 deletions

View File

@ -1,3 +1,31 @@
# gographql # gographql
Exemple d'API GraphQL, PostgresQL, en Go Exemple d'API GraphQL, PostgresQL, en Go
```
go build && go run .
```
## Query
Toute rếquete visant à récupérer une donnée est appellée une 'Query'
```
# Exemple de Query
curl -X POST \
-H 'Content-Type: application/json' \
-d '{"query": "{ user { id,firstname,lastname,roles{name} } }"}' \
http://localhost:8383/
```
## Mutation
Toute requếte visant à modifier une donnée est appellée une 'Mutation'
```
curl -X POST \
-H 'Content-Type: application/json' \
-d '{"query": "mutation { createUser(firstname: \"John\", lastname: \"Snow\") { id,firstname,lastname } }"}' \
http://localhost:8383
```

BIN
graphql

Binary file not shown.

View File

@ -32,6 +32,7 @@ func main() {
httpHandler := handler.New(&handler.Config{ httpHandler := handler.New(&handler.Config{
Schema: &schema, Schema: &schema,
Pretty: true,
}) })
postgres.DBConnect() postgres.DBConnect()

View File

@ -10,7 +10,6 @@ import (
// GetUserQuery returns the queries available against user type. // GetUserQuery returns the queries available against user type.
func GetUserQuery() *graphql.Field { func GetUserQuery() *graphql.Field {
log.Print("GetUserQuery")
return &graphql.Field{ return &graphql.Field{
Type: graphql.NewList(types.UserType), Type: graphql.NewList(types.UserType),
Resolve: func(params graphql.ResolveParams) (interface{}, error) { Resolve: func(params graphql.ResolveParams) (interface{}, error) {