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

feat(modify): BREAKING CHANGE - Change the return result to include warnings #83

Merged
merged 7 commits into from
Jul 24, 2024

Conversation

sandrina-p
Copy link
Collaborator

@sandrina-p sandrina-p commented Jul 24, 2024

Follow-up of #71.

Linear issue (internal)

Now the result is an object with both schema and warn. The warn will be an array of all warnings highlighting unexpected changes. This can help you spot and avoid possible bugs with your modifications.

Before

const schema = modify(yourSchema, config)

Now

const { schema, warnings } = modify(yourSchema, config)

The warnings is an array of objects (list of warnings), each one with a type and message. Eg:

[{
  type: "CHANGE_FIELD_NOT_FOUND",
  message: "'Changing field "unknown_field" was ignored because it does not exist.'"
}]

Remembering the warnings

When using modify(), it will also log a console.warn by default calling you out to handle the warnings on your behalf. For example, report it to your error tracking systems.

You can disable the log by passing muteWarningTip

const { schema, warnings } = modify(yourSchema, {
  muteLogging: true,
})

References:

@sandrina-p sandrina-p self-assigned this Jul 24, 2024
@sandrina-p sandrina-p requested review from danielcardoso5 and eng-almeida and removed request for danielcardoso5 July 24, 2024 08:59
src/modify.js Outdated Show resolved Hide resolved
@sandrina-p sandrina-p force-pushed the pbyr-1417-jsf-modify-module-explicit-warnings branch from 42b31ca to 0229b4b Compare July 24, 2024 11:48
src/modify.js Outdated Show resolved Hide resolved
src/modify.js Outdated Show resolved Hide resolved
@sandrina-p sandrina-p merged commit e07fcec into main Jul 24, 2024
3 checks passed
@sandrina-p sandrina-p deleted the pbyr-1417-jsf-modify-module-explicit-warnings branch July 24, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants