Search in sources :

Example 1 with InputFieldJsonWriter

use of com.apollographql.apollo.internal.json.InputFieldJsonWriter in project apollo-android by apollographql.

the class ApolloServerInterceptor method httpRequestBody.

private RequestBody httpRequestBody(Operation operation) throws IOException {
    Buffer buffer = new Buffer();
    JsonWriter jsonWriter = JsonWriter.of(buffer);
    jsonWriter.setSerializeNulls(true);
    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());
}
Also used : Buffer(okio.Buffer) InputFieldJsonWriter(com.apollographql.apollo.internal.json.InputFieldJsonWriter) JsonWriter(com.apollographql.apollo.internal.json.JsonWriter) InputFieldJsonWriter(com.apollographql.apollo.internal.json.InputFieldJsonWriter)

Aggregations

InputFieldJsonWriter (com.apollographql.apollo.internal.json.InputFieldJsonWriter)1 JsonWriter (com.apollographql.apollo.internal.json.JsonWriter)1 Buffer (okio.Buffer)1