Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@openreplay/tracker-graphql
Advanced tools
Readme
This plugin allows you to capture the GraphQL requests and then search by them.
npm i @openreplay/tracker-graphql
Initialize the @openreplay/tracker
package as usual and load the plugin into it.
The plugin
call will return the function, which receives four variables
operationKind
, operationName
, variables
, result
and returns result
without changes.
import Tracker from '@openreplay/tracker';
import trackerGraphQL from '@openreplay/tracker-graphql';
const tracker = new Tracker({
projectKey: YOUR_PROJECT_KEY,
});
export const recordGraphQL = tracker.plugin(trackerGraphQL());
For Relay you should manually put recordGraphQL
call
to the NetworkLayer
implementation. If you are standard Network.create
way to implement it,
then you should do something like below
import { recordGraphQL } from 'tracker'; // see above for recordGraphQL definition
import { Environment } from 'relay-runtime';
function fetchQuery(operation, variables, cacheConfig, uploadables) {
return fetch('www.myapi.com/resource', {
// ...
})
.then(response => response.json())
.then(result =>
recordGraphQL(operation.operationKind, operation.name, variables, result),
);
}
const network = Network.create(fetchQuery);
See Relay Network Layer for details.
For Apollo you should create a new ApolloLink
with
recordGraphQL
call and put it to your chain like below
import { recordGraphQL } from 'tracker'; // see above for recordGraphQL definition
import { ApolloLink } from 'apollo-link';
const trackerApolloLink = new ApolloLink((operation, forward) => {
return forward(operation).map(result =>
recordGraphQL(
operation.query.definitions[0].operation,
operation.operationName,
operation.variables,
result,
),
);
});
const link = ApolloLink.from([
trackerApolloLink,
// ...
]);
See Apollo Link and Apollo Networking for details.
FAQs
Tracker plugin for GraphQL requests recording
The npm package @openreplay/tracker-graphql receives a total of 1,106 weekly downloads. As such, @openreplay/tracker-graphql popularity was classified as popular.
We found that @openreplay/tracker-graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.