Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: adds http-post example #575

Merged
merged 2 commits into from
Oct 11, 2020
Merged

examples: adds http-post example #575

merged 2 commits into from
Oct 11, 2020

Conversation

chris-ramon
Copy link
Member

@chris-ramon chris-ramon commented Oct 11, 2020

Overview

Test plan

  • Tested that examples/http-post is working as expected:
(http-post)-> go run main.go 
Now server is running on port 8080

Get single todo:
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "{ todo(id:\"b\") { id text done } }" }' \
http://localhost:8080/graphql

Create new todo:
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "mutation { createTodo(text:\"My New todo\") { id text done } }" }' \
http://localhost:8080/graphql

Update todo:
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "mutation { updateTodo(id:\"a\", done: true) { id text done } }" }' \
http://localhost:8080/graphql

Load todo list:
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "{ todoList { id text done } }" }' \
http://localhost:8080/graphql
(graphql)-> curl \
> -X POST \
> -H "Content-Type: application/json" \
> --data '{ "query": "mutation { createTodo(text:\"My New todo\") { id text done } }" }' \
> http://localhost:8080/graphql
{"data":{"createTodo":{"done":false,"id":"XVlBzgba","text":"My New todo"}}}
(graphql)-> curl \
> -X POST \
> -H "Content-Type: application/json" \
> --data '{ "query": "mutation { createTodo(text:\"My New todo\") { id text done } }" }' \
> http://localhost:8080/graphql | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   153  100    76  100    77  11615  11768 --:--:-- --:--:-- --:--:-- 12833
{
  "data": {
    "createTodo": {
      "done": false,
      "id": "XVlBzgba",
      "text": "My New todo"
    }
  }
}
(graphql)-> curl \
> -X POST \
> -H "Content-Type: application/json" \
> --data '{ "query": "{ todo(id:\"XVlBzgba\") { id text done } }" }' \
> http://localhost:8080/graphql | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   127  100    70  100    57  11554   9409 --:--:-- --:--:-- --:--:-- 11666
{
  "data": {
    "todo": {
      "done": false,
      "id": "XVlBzgba",
      "text": "My New todo"
    }
  }
}
(graphql)-> curl \
> -X POST \
> -H "Content-Type: application/json" \
> --data '{ "query": "mutation { updateTodo(id:\"XVlBzgba\", done: true) { id text done } }" }' \
> http://localhost:8080/graphql | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   159  100    75  100    84  12735  14263 --:--:-- --:--:-- --:--:-- 16800
{
  "data": {
    "updateTodo": {
      "done": true,
      "id": "XVlBzgba",
      "text": "My New todo"
    }
  }
}
(graphql)-> curl \
> -X POST \
> -H "Content-Type: application/json" \
> --data '{ "query": "{ todoList { id text done } }" }' \
> http://localhost:8080/graphql | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   119  100    75  100    44  13347   7830 --:--:-- --:--:-- --:--:-- 15000
{
  "data": {
    "todoList": [
      {
        "done": true,
        "id": "XVlBzgba",
        "text": "My New todo"
      }
    ]
  }
}

@chris-ramon chris-ramon self-assigned this Oct 11, 2020
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.426% when pulling 089f1ba on examples-http-post into 05c348c on master.

@chris-ramon chris-ramon merged commit dd05d5e into master Oct 11, 2020
@chris-ramon chris-ramon deleted the examples-http-post branch October 11, 2020 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POST Example
3 participants