Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warn about mutating data in option transform #443

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 1 addition & 119 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,125 +50,7 @@ const client = new ApolloClient({

## Options

```typescript
export interface FullOptions {
/**
* Determines if the given operation should be handled or discarded.
*
* If undefined, all operations will be included.
*/
shouldHandleOperation: undefined | ((operation: Operation) => boolean);

/**
* The uri of the GraphQL endpoint.
*
* Used to add context information, e.g. to breadcrumbs.
*
* Defaults to undefined.
*/
uri: undefined | string;

/**
* Set the Sentry transaction name to the GraphQL operation name.
*
* May be overwritten by other parts of your app.
*
* Defaults to true.
*/
setTransaction: true | false;

/**
* Narrow Sentry's fingerprint by appending the GraphQL operation name to the {{default}} key.
*
* Only the last executed operation will be added, not every operation that's been through the link.
* May be overwritten by other parts of your app.
*
* Defaults to true.
*/
setFingerprint: true | false;

/**
* Attach a breadcrumb for executed GraphQL operations.
*
* The following information will be included by default:
* {
* type: 'http',
* category: `graphql.${operationType}`,
* message: operationName,
* level: errors ? 'error' : 'info',
* }
*/
attachBreadcrumbs: AttachBreadcrumbsOptions | false;
}

export type AttachBreadcrumbsOptions = {
/**
* Include the full query string?
*
* Defaults to false.
*/
includeQuery: false | true;

/**
* Include the variable values?
*
* Be careful not to leak sensitive information or send too much data.
*
* Defaults to false.
*/
includeVariables: false | true;

/**
* Include the fetched result (data, errors, extensions)?
*
* Be careful not to leak sensitive information or send too much data.
*
* Defaults to false.
*/
includeFetchResult: false | true;

/**
* Include the response error?
*
* Be careful not to leak sensitive information or send too much data.
*
* Defaults to false.
*/
includeError: false | true;

/**
* Include the contents of the Apollo Client cache?
*
* This is mostly useful for debugging purposes and not recommended for production environments,
* see "Be careful what you include", unless carefully combined with `beforeBreadcrumb`.
*
* Defaults to false.
*/
includeCache: false | true;

/**
* Include arbitrary data from the `ApolloContext`?
*
* Accepts a list of keys in dot notation, e.g. `foo.bar`. Can be useful to include extra
* information such as headers.
*
* Defaults to false.
*/
includeContext: false | NonEmptyArray<string>;

/**
* Modify the breadcrumb right before it is sent.
*
* Can be used to add additional data from the operation or clean up included data.
* Very useful in combination with options like `includeVariables` and `includeContext`.
*
* Defaults to undefined.
*/
transform:
| undefined
| ((breadcrumb: GraphQLBreadcrumb, operation: Operation) => Breadcrumb);
};
```
See [src/options.ts](src/options.ts).

### Compatibility with other Apollo Links

Expand Down
3 changes: 2 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ export type AttachBreadcrumbsOptions = {
includeContext: false | NonEmptyArray<string>;

/**
* Modify the breadcrumb right before it is sent.
* Allows to return a modified copy of the breadcrumb right before it is sent.
*
* Can be used to add additional data from the operation or clean up included data.
* Do not mutate the data within the breadcrumb object, as it references the original.
* Very useful in combination with options like `includeVariables` and `includeContext`.
*
* Defaults to undefined.
Expand Down