daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Feb 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.testamplify;
  2.  
  3.     import android.support.v7.app.AppCompatActivity;
  4.     import android.os.Bundle;
  5.     import android.util.Log;
  6.  
  7.     import com.amazonaws.mobile.config.AWSConfiguration;
  8.     import com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient;
  9.     import com.apollographql.apollo.GraphQLCall;
  10.     import com.apollographql.apollo.exception.ApolloException;
  11.  
  12.     import javax.annotation.Nonnull;
  13.  
  14.         public class MainActivity extends AppCompatActivity {
  15.  
  16.         private AWSAppSyncClient mAWSAppSyncClient;
  17.  
  18.         @Override
  19.         protected void onCreate(Bundle savedInstanceState) {
  20.             super.onCreate(savedInstanceState);
  21.             setContentView(R.layout.activity_main);
  22.             mAWSAppSyncClient = AWSAppSyncClient.builder()
  23.                     .context(getApplicationContext())
  24.                     .awsConfiguration(new AWSConfiguration(getApplicationContext()))
  25.                     .build();
  26. runMutation();
  27.         }
  28.  
  29.         public void runMutation(){
  30.             CreateTodoInput createTodoInput = CreateTodoInput.builder().
  31.                     name("Use AppSync").
  32.                     description("Realtime and Offline").
  33.                     build();
  34.  
  35.             mAWSAppSyncClient.mutate(CreateTodoMutation.builder().input(createTodoInput).build())
  36.                     .enqueue(mutationCallback);
  37.         }
  38.  
  39.         private GraphQLCall.Callback<CreateTodoMutation.Data> mutationCallback = new GraphQLCall.Callback<CreateTodoMutation.Data>() {
  40.             @Override
  41.             public void onResponse(@Nonnull Response<CreateTodoMutation.Data> response) {
  42.                 Log.i("Results", "Added Todo");
  43.             }
  44.  
  45.             @Override
  46.             public void onFailure(@Nonnull ApolloException e) {
  47.                 Log.e("Error", e.toString());
  48.             }
  49.         };
  50.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top