Tabnine Logo
InputFieldJsonWriter.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.apollographql.apollo.internal.json.InputFieldJsonWriter
constructor

Best Java code snippets using com.apollographql.apollo.internal.json.InputFieldJsonWriter.<init> (Showing top 14 results out of 315)

origin: apollographql/apollo-android

@Override public void writeObject(InputFieldMarshaller marshaller) throws IOException {
 if (marshaller == null) {
  jsonWriter.nullValue();
 } else {
  jsonWriter.beginObject();
  marshaller.marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
  jsonWriter.endObject();
 }
}
origin: apollographql/apollo-android

@Before
public void setUp() throws IOException {
 jsonBuffer = new Buffer();
 jsonWriter = JsonWriter.of(jsonBuffer);
 jsonWriter.setSerializeNulls(true);
 jsonWriter.beginObject();
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter,
   new ScalarTypeAdapters(Collections.<ScalarType, CustomTypeAdapter>emptyMap()));
}
origin: apollographql/apollo-android

@Test
public void writeCustomJson() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLJson.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLJson((Map<String, Object>) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 Map<String, Object> objectMap = new LinkedHashMap<>();
 objectMap.put("booleanField", true);
 objectMap.put("stringField", "someValue");
 objectMap.put("numberField", 100);
 objectMap.put("objectField", new UnmodifiableMapBuilder().put("someField", "someValue").build());
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLJson.class), objectMap);
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLJson.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":{\"booleanField\":true,\"stringField\":\"someValue\",\"numberField\":100,\"objectField\":{\"someField\":\"someValue\"}},\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomNumber() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLNumber.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLNumber((Number) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLNumber.class), BigDecimal.valueOf(100.1));
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLNumber.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":100.1,\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomString() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLString.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLString((String) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLString.class), "someValue");
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLString.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":\"someValue\",\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomBoolean() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLBoolean.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLBoolean((Boolean) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLBoolean.class), true);
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLBoolean.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":true,\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomJsonString() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLJsonString.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLJsonString((String) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLJsonString.class), "{\"someField\": \"someValue\"}");
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLJsonString.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":\"{\\\"someField\\\": \\\"someValue\\\"}\",\"someNullField\":null");
}
origin: apollographql/apollo-android

 @Override public void writeToJson(@NotNull JsonWriter writer) throws IOException {
  checkNotNull(writer, "writer == null");
  writer.name(JSON_KEY_ID).value(subscriptionId);
  writer.name(JSON_KEY_TYPE).value(TYPE);
  writer.name(JSON_KEY_PAYLOAD).beginObject();
  writer.name(JSON_KEY_QUERY).value(subscription.queryDocument().replaceAll("\\n", ""));
  writer.name(JSON_KEY_VARIABLES).beginObject();
  subscription.variables().marshaller().marshal(new InputFieldJsonWriter(writer, scalarTypeAdapters));
  writer.endObject();
  writer.name(JSON_KEY_OPERATION_NAME).value(subscription.name().name());
  writer.endObject();
 }
}
origin: apollographql/apollo-android

 static ByteString httpRequestBody(Operation operation, ScalarTypeAdapters scalarTypeAdapters,
   boolean writeQueryDocument) throws IOException {
  Buffer buffer = new Buffer();
  JsonWriter jsonWriter = JsonWriter.of(buffer);
  jsonWriter.setSerializeNulls(true);
  jsonWriter.beginObject();
  jsonWriter.name("operationName").value(operation.name().name());
  jsonWriter.name("variables").beginObject();
  operation.variables().marshaller().marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
  jsonWriter.endObject();
  jsonWriter.name("extensions")
    .beginObject()
    .name("persistedQuery")
    .beginObject()
    .name("version").value(1)
    .name("sha256Hash").value(operation.operationId())
    .endObject()
    .endObject();
  if (writeQueryDocument) {
   jsonWriter.name("query").value(operation.queryDocument().replaceAll("\\n", ""));
  }
  jsonWriter.endObject();
  jsonWriter.close();
  return buffer.readByteString();
 }
}
origin: com.amazonaws/aws-android-sdk-appsync-runtime

 @Override public void writeObject(InputFieldMarshaller marshaller) throws IOException {
  if (marshaller != null) {
   jsonWriter.beginObject();
   marshaller.marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
   jsonWriter.endObject();
  }
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

 @Override public void writeObject(InputFieldMarshaller marshaller) throws IOException {
  if (marshaller != null) {
   jsonWriter.beginObject();
   marshaller.marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
   jsonWriter.endObject();
  }
 }
}
origin: awslabs/aws-mobile-appsync-sdk-android

private String httpRequestBody(Operation operation) throws IOException {
  Buffer buffer = new Buffer();
  JsonWriter jsonWriter = JsonWriter.of(buffer);
  jsonWriter.beginObject();
  jsonWriter.name("query").value(operation.queryDocument().replaceAll("\\n", ""));
  jsonWriter.name("variables").beginObject();
  operation.variables().marshaller().marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
  jsonWriter.endObject();
  jsonWriter.endObject();
  jsonWriter.close();
  return buffer.readUtf8();
}
origin: awslabs/aws-mobile-appsync-sdk-android

private RequestBody httpRequestBody(Operation operation) throws IOException {
 Buffer buffer = new Buffer();
 JsonWriter jsonWriter = JsonWriter.of(buffer);
 jsonWriter.beginObject();
 if (sendOperationIdentifiers) {
  jsonWriter.name("id").value(operation.operationId());
 } else {
  jsonWriter.name("query").value(operation.queryDocument().replaceAll("\\n", ""));
 }
 jsonWriter.name("variables").beginObject();
 operation.variables().marshaller().marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
 jsonWriter.endObject();
 jsonWriter.endObject();
 jsonWriter.close();
 return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
}
origin: com.amazonaws/aws-android-sdk-appsync-runtime

private RequestBody httpRequestBody(Operation operation) throws IOException {
 Buffer buffer = new Buffer();
 JsonWriter jsonWriter = JsonWriter.of(buffer);
 jsonWriter.beginObject();
 if (sendOperationIdentifiers) {
  jsonWriter.name("id").value(operation.operationId());
 } else {
  jsonWriter.name("query").value(operation.queryDocument().replaceAll("\\n", ""));
 }
 jsonWriter.name("variables").beginObject();
 operation.variables().marshaller().marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters));
 jsonWriter.endObject();
 jsonWriter.endObject();
 jsonWriter.close();
 return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
}
com.apollographql.apollo.internal.jsonInputFieldJsonWriter<init>

Popular methods of InputFieldJsonWriter

  • writeString
  • writeBoolean
  • writeNumber
  • writeCustom
  • writeDouble
  • writeInt
  • writeList
  • writeLong
  • writeMap
  • writeObject

Popular in Java

  • Updating database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now