Skip to content

Commit

Permalink
added mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
florent champigny committed Jul 18, 2017
1 parent 6783e0c commit e4a4af9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ then execute with `enqueue(SuccessCallback, ErrorCallback)`

By default the success response is the Json (as String)

```
```java
okGraphql
.query("{" +
" hero {" +
Expand All @@ -62,7 +62,7 @@ okGraphql
You can also inflate a POJO with the returned Json using `.cast(CLASS)`
This will use the `converter` assigned to your OkGraphQl

```
```java
class Character {
String name;
}
Expand Down Expand Up @@ -121,7 +121,7 @@ okGraphql

Use Fields Builders instead of Strings to create dynamically your queries

```
```java
okGraphql

.query(newField()
Expand All @@ -147,13 +147,30 @@ This example will generate the query :

# Mutations

//TODO
Mutations are easy to execute with OkGraphQl

```java
okGraphql
.mutation("CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {" +
" createReview(episode: $ep, review: $review) {" +
" stars" +
" commentary" +
" }" +
"}")
.variable("ep", "JEDI")
.variable("review", "{ \"stars\": 5, \"commentary\": \"This is a great movie!\"")
.enqueue(responseString -> {
text1.setText(responseString);
}, error -> {
text1.setText(error.getLocalizedMessage());
});
```

# Fragments

Use `.fragment(code)` to append a fragment on your request

```
```java
okGraphql

.body("{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,29 @@ protected void onCreate(Bundle savedInstanceState) {

//query_hero();
//query_hero_enqueue();
query_variables_directives();
//
//query_variables_directives();

//query_hero_built();
//query_argument_built();
//fragment(text3);
//mutation();
mutation();
}

private void mutation() {
okGraphql
.mutation("CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {" +
" createReview(episode: $ep, review: $review) {" +
" stars" +
" commentary" +
" }" +
"}")
.variable("ep", "JEDI")
.variable("review", "{ \"stars\": 5, \"commentary\": \"This is a great movie!\"")
.enqueue(responseString -> {
text1.setText(responseString);
}, error -> {
text1.setText(error.getLocalizedMessage());
});
}

private void query_hero_enqueue() {
Expand Down

0 comments on commit e4a4af9

Please sign in to comment.