* Send query to GraphQL endpoint over http. * Returns a response as a promise. * * ```js * * const response = await I.sendQuery('{ users { name email }}'); * // with variables * const response = await I.sendQuery( * 'query getUser($id: ID) { user(id: $id) { name email }}',
(query, variables, options = {}, headers = {})
| 150 | * @return Promise<any> |
| 151 | */ |
| 152 | async sendQuery(query, variables, options = {}, headers = {}) { |
| 153 | if (typeof query !== 'string') { |
| 154 | throw new Error(`query expected to be a String, instead received ${typeof query}`) |
| 155 | } |
| 156 | const operation = { |
| 157 | query, |
| 158 | variables, |
| 159 | ...options, |
| 160 | } |
| 161 | const request = this._prepareGraphQLRequest(operation, headers) |
| 162 | return this._executeQuery(request) |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Send query to GraphQL endpoint over http |
no test coverage detected