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: Add and export makeSuccessResult and makeErrorResult helpers #138

Merged
merged 3 commits into from
Apr 8, 2024

Conversation

gustavoguichard
Copy link
Collaborator

Often times, especially in tests, we want to construct the Result type and we have to type all the structure.
These functions should help with that by allowing us to construct an ErrorResult like so:

// before: 
const error: ErrorResult = {
  success: false,
  errors: [myError],
  environmentErrors: [],
  inputErrors: [],
}

// after:
const error: ErrorResult = makeErrorResult({ errors: [MyError] })

or a SuccessResult like so:

// before: 
const result: SuccessResult = {
  success: true,
  data,
  errors: [],
  inputErrors: [],
  environmentErrors: [],
}

// after:
const result: SuccessResult = makeSuccessResult(data)

@gustavoguichard gustavoguichard force-pushed the make-error-and-success branch from c6545e2 to 5b807f1 Compare April 8, 2024 17:17
Copy link
Contributor

@diogob diogob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@diogob diogob merged commit c81b27b into main Apr 8, 2024
2 checks passed
@diogob diogob deleted the make-error-and-success branch April 8, 2024 17:37
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.

2 participants