Skip to content

Commit

Permalink
Suppress missing field logging in xplat logger not Relay itself
Browse files Browse the repository at this point in the history
Reviewed By: tyao1

Differential Revision: D62905072

fbshipit-source-id: eca3d86c1f9607d5a959e752c5bfc97874035abb
  • Loading branch information
captbaritone authored and facebook-github-bot committed Sep 19, 2024
1 parent e133fea commit 5f4388e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ describe('handlePotentialSnapshotErrors', () => {
);
}).toThrowError(/^Relay: Missing data for one or more fields/);

// expect(relayFieldLogger).toHaveBeenCalledTimes(1);
// expect(relayFieldLogger).toHaveBeenCalledWith({
// fieldPath: '',
// kind: 'missing_expected_data.throw',
// owner: '',
// });
expect(relayFieldLogger).toHaveBeenCalledTimes(1);
expect(relayFieldLogger).toHaveBeenCalledWith({
fieldPath: '',
kind: 'missing_expected_data.throw',
owner: '',
});
});

it("logs missing data but doesn't throw when throwOnFieldError is false", () => {
Expand All @@ -181,12 +181,12 @@ describe('handlePotentialSnapshotErrors', () => {
);
}).not.toThrow();

// expect(relayFieldLogger).toHaveBeenCalledTimes(1);
// expect(relayFieldLogger).toHaveBeenCalledWith({
// fieldPath: '',
// kind: 'missing_expected_data.log',
// owner: '',
// });
expect(relayFieldLogger).toHaveBeenCalledTimes(1);
expect(relayFieldLogger).toHaveBeenCalledWith({
fieldPath: '',
kind: 'missing_expected_data.log',
owner: '',
});
});

it("logs missing data but doesn't throw when throwOnFieldError is false", () => {
Expand All @@ -209,12 +209,12 @@ describe('handlePotentialSnapshotErrors', () => {
);
}).not.toThrow();

// expect(relayFieldLogger).toHaveBeenCalledTimes(1);
// expect(relayFieldLogger).toHaveBeenCalledWith({
// fieldPath: '',
// kind: 'missing_expected_data.log',
// owner: '',
// });
expect(relayFieldLogger).toHaveBeenCalledTimes(1);
expect(relayFieldLogger).toHaveBeenCalledWith({
fieldPath: '',
kind: 'missing_expected_data.log',
owner: '',
});
});
});

Expand Down Expand Up @@ -305,7 +305,7 @@ describe('handlePotentialSnapshotErrors', () => {
);
}).not.toThrow();

expect(relayFieldLogger).toHaveBeenCalledTimes(1);
expect(relayFieldLogger).toHaveBeenCalledTimes(2);
expect(relayFieldLogger).toHaveBeenCalledWith({
error: {
message: 'testMessage',
Expand All @@ -316,11 +316,11 @@ describe('handlePotentialSnapshotErrors', () => {
kind: 'relay_field_payload.error',
owner: 'testOwner',
});
// expect(relayFieldLogger).toHaveBeenCalledWith({
// fieldPath: '',
// kind: 'missing_expected_data.log',
// owner: '',
// });
expect(relayFieldLogger).toHaveBeenCalledWith({
fieldPath: '',
kind: 'missing_expected_data.log',
owner: '',
});
});

it('logs', () => {
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('handlePotentialSnapshotErrors', () => {
/^Relay: Unexpected response payload - this object includes an errors property in which you can access the underlying errors/,
);

expect(relayFieldLogger).toHaveBeenCalledTimes(1);
expect(relayFieldLogger).toHaveBeenCalledTimes(2);
expect(relayFieldLogger).toHaveBeenCalledWith({
error: {
message: 'testMessage',
Expand All @@ -402,11 +402,11 @@ describe('handlePotentialSnapshotErrors', () => {
owner: 'testOwner',
});

// expect(relayFieldLogger).toHaveBeenCalledWith({
// fieldPath: '',
// kind: 'missing_expected_data.throw',
// owner: '',
// });
expect(relayFieldLogger).toHaveBeenCalledWith({
fieldPath: '',
kind: 'missing_expected_data.throw',
owner: '',
});
});
});

Expand Down
6 changes: 3 additions & 3 deletions packages/relay-runtime/util/handlePotentialSnapshotErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function handleFieldErrors(
for (const fieldError of errorResponseFields) {
const {path, owner, error} = fieldError;
if (fieldError.type === 'MISSING_DATA') {
// _logMissingData(environment, shouldThrow);
logMissingData(environment, shouldThrow);
} else {
environment.relayFieldLogger({
kind: 'relay_field_payload.error',
Expand All @@ -69,7 +69,7 @@ function handleFieldErrors(
}
}

function _logMissingData(environment: IEnvironment, throwing: boolean) {
function logMissingData(environment: IEnvironment, throwing: boolean) {
if (!throwing) {
environment.relayFieldLogger({
kind: 'missing_expected_data.log',
Expand Down Expand Up @@ -122,7 +122,7 @@ function handleMissingDataError(
environment: IEnvironment,
throwOnFieldErrorDirective: boolean,
) {
// _logMissingData(environment, throwOnFieldErrorDirective);
logMissingData(environment, throwOnFieldErrorDirective);

if (throwOnFieldErrorDirective) {
throw new RelayFieldError(`Relay: Missing data for one or more fields`);
Expand Down

0 comments on commit 5f4388e

Please sign in to comment.