MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / query

Function query

src/environmentd/src/http/static/js/fetch.js:18–35  ·  view source on GitHub ↗

* Execute a SQL query against the /api/sql endpoint. * * @param {string} sql - SQL query string * @returns {Promise } - The parsed JSON response

(sql)

Source from the content-addressed store, hash-verified

16 * @returns {Promise<Object>} - The parsed JSON response
17 */
18async function query(sql) {
19 const response = await fetch('/api/sql', {
20 method: 'POST',
21 body: JSON.stringify({ query: sql }),
22 headers: { 'Content-Type': 'application/json' },
23 });
24 if (!response.ok) {
25 const text = await response.text();
26 throw `request failed: ${response.status} ${response.statusText}: ${text}`;
27 }
28 const data = await response.json();
29 for (const result of data.results) {
30 if (result.error) {
31 throw `SQL error: ${result.error.message}`;
32 }
33 }
34 return data;
35}

Callers 7

discoverEndpointsFunction · 0.70
ClusterReplicaViewFunction · 0.70
loadFunction · 0.70
getCreateViewFunction · 0.70
ClusterReplicaViewFunction · 0.70
loadFunction · 0.70
getCreateViewFunction · 0.70

Calls 2

fetchFunction · 0.50
jsonMethod · 0.45

Tested by

no test coverage detected