Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Last active November 12, 2020 18:11
Show Gist options
  • Select an option

  • Save jasonLaster/297ae56a420c3b71a98cbb88cf1ebac9 to your computer and use it in GitHub Desktop.

Select an option

Save jasonLaster/297ae56a420c3b71a98cbb88cf1ebac9 to your computer and use it in GitHub Desktop.
const fetch = require("node-fetch").default;
const https = require("https");
const passwordThatShouldBeHidden = "<>";
async function fetchGraphQL(query, name, variables = {}) {
const result = await fetch("https://graphql.replay.io/v1/graphql", {
method: "POST",
headers: {
"x-hasura-admin-secret": passwordThatShouldBeHidden,
},
body: JSON.stringify({
query,
name,
variables,
}),
});
return await result.json();
}
function addTestRecordingId(recordingId) {
try {
const options = {
hostname: "test-inbox.replay.io",
port: 8004,
path: `/${recordingId}`,
method: "GET",
};
const req = https.request(options, res => {
console.log("AddTestRecordingId", recordingId, res.statusCode);
});
req.end();
} catch (e) {
console.error("addTestRecordingId failed", e);
}
}
(async () => {
const {data: {recordings}} = await fetchGraphQL(`query todaysRecordings {
recordings(where: {
user_id: {_eq: "8bc7140d-993f-4374-8b97-7cdfb1f7e484"}
date: {_gte:"2020-11-12"}
}) {
recording_id
title
date
user {
name
}
}
}
`)
recordings.forEach((recording) => addTestRecordingId(recording.recording_id))
console.log(JSON.stringify(recordings, null, 2))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment