Skip to content

Instantly share code, notes, and snippets.

@akoenig
Last active March 4, 2018 07:25
Show Gist options
  • Select an option

  • Save akoenig/e8614ec2372ef9daec531ef61743d88a to your computer and use it in GitHub Desktop.

Select an option

Save akoenig/e8614ec2372ef9daec531ef61743d88a to your computer and use it in GitHub Desktop.
Medium: M2M in GraphQL context (Invoking binding factory and perform and execute query)
import { createTelemetryBinding } from "./binding";
const app = async () => {
const telemetry = await createTelemetryBinding(
"https://kqxrmk1pr7.lp.gql.zone/graphql"
);
while (true) {
const userTelemetry = await telemetry.query.user({}, {});
// You could write the data to a different storage system,
// e.g. time-series database, etc.
console.log(userTelemetry);
// Wait for one hour before fetching the user telemetry again
await new Promise(resolve => setTimeout(resolve, 60 * 1000 * 60));
}
};
app().catch(err => {
process.exit(1);
console.error(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment