How to disable compression?

it seems that by default compression is enabled. How do I disable it???
I did the following in javascript

  let a =  await fetch(`localhost:8080/graphql`, {
  method: 'POST',
  headers: {'Content-Type': 'application/graphql'},
  body: `mutation {
  addUser(input: {name: "pp", created_at: "2019", username: "as", password: "afsafasf"}) {
    numUids
  }
`

and I get this

Fething <ref *1> Gunzip {
  _writeState: Uint32Array(2) [ 0, 0 ],
  _readableState: ReadableState {
    objectMode: false,
    highWaterMark: 16384,
    buffer: BufferList { head: null, tail: null, length: 0 },
    length: 0,
    pipes: [],
    flowing: null,
    ended: false,
    endEmitted: false,
    reading: false,
    sync: false,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    destroyed: false,
    errored: null,
    closed: false,
    closeEmitted: false,
    defaultEncoding: 'utf8',
    awaitDrainWriters: null,
    multiAwaitDrain: false,
    readingMore: false,
    decoder: null,
    encoding: null,
    [Symbol(kPaused)]: null
  },
  _events: [Object: null prototype] {
    prefinish: [Function: prefinish],
    unpipe: [Function: onunpipe],
    error: [ [Function: onerror], [Function (anonymous)] ],
    close: [Function: bound onceWrapper] { listener: [Function: onclose] },
    finish: [Function: bound onceWrapper] { listener: [Function: onfinish] }
  },
  _eventsCount: 5,
  _maxListeners: undefined,
  _writableState: WritableState {
    objectMode: false,
    highWaterMark: 16384,
    finalCalled: false,
    needDrain: false,
    ending: true,
    ended: true,
    finished: false,
    destroyed: false,
    decodeStrings: true,
    defaultEncoding: 'utf8',
    length: 380,
    writing: true,
    corked: 0,
    sync: false,
    bufferProcessing: false,
    onwrite: [Function: bound onwrite],
    writecb: [Function: nop],
    writelen: 380,
    afterWriteTickInfo: null,
    buffered: [],
    bufferedIndex: 0,
    allBuffers: true,
    allNoop: true,
    pendingcb: 1,
    prefinished: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    errored: null,
    closed: false
  },
  allowHalfOpen: true,
  bytesWritten: 0,
  _handle: Zlib {
    onerror: [Function: zlibOnError],
    buffer: <Buffer 1f 8b 08 00 00 00 00 00 00 ff 7c 90 cd 6e db 30 10 84 5f 85 d8 4b 2f 4a 21 ca ae c5 f2 d6 07 e8 1f e0 5e 1a f8 b0 36 57 8e 00 8a 54 96 cb b4 86 a1 77 ... 330 more bytes>,
    cb: [Function: bound afterTransform],
    availOutBefore: 16384,
    availInBefore: 380,
    inOff: 0,
    flushFlag: 2,
    [Symbol(owner_symbol)]: [Circular *1]
  },
  _outBuffer: <Buffer 7b 22 65 72 72 6f 72 73 22 3a 5b 7b 22 6d 65 73 73 61 67 65 22 3a 22 63 6f 75 6c 64 6e 27 74 20 72 65 77 72 69 74 65 20 6d 75 74 61 74 69 6f 6e 20 61 ... 16334 more bytes>,
  _outOffset: 0,
  _chunkSize: 16384,
  _defaultFlushFlag: 2,
  _finishFlushFlag: 2,
  _defaultFullFlushFlag: 3,
  _info: undefined,
  _maxOutputLength: 4294967295,
  _level: -1,
  _strategy: 0,
  [Symbol(kCapture)]: false,
  [Symbol(kTransformState)]: {
    afterTransform: [Function: bound afterTransform],
    needTransform: false,
    transforming: true,
    writecb: [Function: bound onwrite],
    writechunk: <Buffer 1f 8b 08 00 00 00 00 00 00 ff 7c 90 cd 6e db 30 10 84 5f 85 d8 4b 2f 4a 21 ca ae c5 f2 d6 07 e8 1f e0 5e 1a f8 b0 36 57 8e 00 8a 54 96 cb b4 86 a1 77 ... 330 more bytes>,
    writeencoding: 'buffer'
  },
  [Symbol(kError)]: null
}

This was the response. I guess compression is on. How do I disable it???

That’s a promise. Are you returning it right?

let res = await results.json();

But I think it would be better to do something like:

fetch('localhost:8080/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/graphql',
  },
  body: `mutation {
  addUser(input: {name: "pp", created_at: "2019", username: "as", password: "afsafasf"}) {
    numUids
  }
`
})
  .then((res) => res.json())
  .then((result) => console.log(result));

I would create a function for this too. To not be repetitive.

1 Like

Oh thanks, I am new to javascript so thank you so much.

1 Like