@Override public void writeObject(InputFieldMarshaller marshaller) throws IOException { if (marshaller != null) { SortedInputFieldMapWriter nestedWriter = new SortedInputFieldMapWriter(fieldNameComparator); marshaller.marshal(nestedWriter); list.add(nestedWriter.buffer); } }
@Override public void writeObject(@NotNull String fieldName, InputFieldMarshaller marshaller) throws IOException { if (marshaller == null) { buffer.put(fieldName, null); } else { SortedInputFieldMapWriter nestedWriter = new SortedInputFieldMapWriter(fieldNameComparator); marshaller.marshal(nestedWriter); buffer.put(fieldName, nestedWriter.buffer); } }
@Override public void writeObject(InputFieldMarshaller marshaller) throws IOException { if (marshaller == null) { jsonWriter.nullValue(); } else { jsonWriter.beginObject(); marshaller.marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters)); jsonWriter.endObject(); } }
private Object resolveVariableArgument(Map<String, Object> objectMap, Operation.Variables variables) { Object variable = objectMap.get(ResponseField.VARIABLE_NAME_KEY); //noinspection SuspiciousMethodCalls Object resolvedVariable = variables.valueMap().get(variable); if (resolvedVariable == null) { return null; } else if (resolvedVariable instanceof Map) { //noinspection unchecked return resolveArguments((Map<String, Object>) resolvedVariable, variables); } else if (resolvedVariable instanceof InputType) { try { SortedInputFieldMapWriter inputFieldMapWriter = new SortedInputFieldMapWriter(argumentNameComparator); ((InputType) resolvedVariable).marshaller().marshal(inputFieldMapWriter); return resolveArguments(inputFieldMapWriter.map(), variables); } catch (IOException e) { // should never happen throw new RuntimeException(e); } } else { return resolvedVariable; } } }
@Override public void writeObject(@NotNull String fieldName, InputFieldMarshaller marshaller) throws IOException { checkNotNull(fieldName, "fieldName == null"); if (marshaller != null) { jsonWriter.name(fieldName).beginObject(); marshaller.marshal(this); jsonWriter.endObject(); } else { jsonWriter.name(fieldName).nullValue(); } }
@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(); } }
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(); } }
@Override public void writeObject(InputFieldMarshaller marshaller) throws IOException { if (marshaller != null) { jsonWriter.beginObject(); marshaller.marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters)); jsonWriter.endObject(); } } }
@Override public void writeObject(InputFieldMarshaller marshaller) throws IOException { if (marshaller != null) { jsonWriter.beginObject(); marshaller.marshal(new InputFieldJsonWriter(jsonWriter, scalarTypeAdapters)); jsonWriter.endObject(); } } }
@Override public void writeObject(@Nonnull String fieldName, InputFieldMarshaller marshaller) throws IOException { checkNotNull(fieldName, "fieldName == null"); if (marshaller != null) { jsonWriter.name(fieldName).beginObject(); marshaller.marshal(this); jsonWriter.endObject(); } else { jsonWriter.name(fieldName).nullValue(); } }
@Override public void writeObject(@Nonnull String fieldName, InputFieldMarshaller marshaller) throws IOException { checkNotNull(fieldName, "fieldName == null"); if (marshaller != null) { jsonWriter.name(fieldName).beginObject(); marshaller.marshal(this); jsonWriter.endObject(); } else { jsonWriter.name(fieldName).nullValue(); } }
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(); }
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()); }
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()); }