openreplay/tracker/tracker-graphql/src/index.ts
2021-05-03 13:31:55 +02:00

28 lines
612 B
TypeScript

import { App, Messages } from '@openreplay/tracker';
export default function() {
return (app: App | null) => {
if (app === null) {
return (_1: string, _2: string, _3: any, result: any) => result;
}
return (
operationKind: string,
operationName: string,
variables: any,
result: any,
) => {
try {
app.send(
Messages.GraphQL(
operationKind,
operationName,
JSON.stringify(variables),
JSON.stringify(result),
),
);
} finally {
return result;
}
};
};
}