MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / _executeQuery

Method _executeQuery

lib/helper/GraphQL.js:79–113  ·  view source on GitHub ↗

* Executes query via axios call * * @param {object} request

(request)

Source from the content-addressed store, hash-verified

77 * @param {object} request
78 */
79 async _executeQuery(request) {
80 this.axios.defaults.timeout = request.timeout || this.options.timeout
81
82 if (this.headers && this.headers.auth) {
83 request.auth = this.headers.auth
84 }
85
86 request.headers = Object.assign(request.headers, {
87 'Content-Type': 'application/json',
88 })
89
90 request.headers = { ...this.headers, ...request.headers }
91
92 if (this.options.onRequest) {
93 await this.options.onRequest(request)
94 }
95
96 this.debugSection('Request', JSON.stringify(request))
97
98 let response
99 try {
100 response = await this.axios(request)
101 } catch (err) {
102 if (!err.response) throw err
103 this.debugSection('Response', `Response error. Status code: ${err.response.status}`)
104 response = err.response
105 }
106
107 if (this.options.onResponse) {
108 await this.options.onResponse(response)
109 }
110
111 this.debugSection('Response', JSON.stringify(response.data))
112 return response
113 }
114
115 /**
116 * Prepares request for axios call

Callers 2

sendQueryMethod · 0.95
sendMutationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected