diff --git a/README.md b/README.md index c504d58..e013d06 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,31 @@ # gographql -Exemple d'API GraphQL, PostgresQL, en Go \ No newline at end of file +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 + +``` \ No newline at end of file diff --git a/graphql b/graphql index 49ab348..ed1aa99 100755 Binary files a/graphql and b/graphql differ diff --git a/main.go b/main.go index 5c7fe96..019002e 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,7 @@ func main() { httpHandler := handler.New(&handler.Config{ Schema: &schema, + Pretty: true, }) postgres.DBConnect() diff --git a/queries/user.go b/queries/user.go index ce3fc49..2ddb589 100644 --- a/queries/user.go +++ b/queries/user.go @@ -10,7 +10,6 @@ import ( // GetUserQuery returns the queries available against user type. func GetUserQuery() *graphql.Field { - log.Print("GetUserQuery") return &graphql.Field{ Type: graphql.NewList(types.UserType), Resolve: func(params graphql.ResolveParams) (interface{}, error) {