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

Rename "errorHere()" to thisError #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion CLIENT-ERRORS-SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const findCodes = (error: ApolloError | GraphQLError): PropheticErrorCode[] => {
return [PropheticErrorCode.CodeLessError];
}

export const errorHere = (error: ApolloError | GraphQLError | undefined ) => {
export const thisError = (error: ApolloError | GraphQLError | undefined ) => {
if(!error) {
return new PropheticError([]);
}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

* Generate **Server-side** **throwable** errors in your resolvers like `throw new NotAProphetError()`
* Expose **machine readable** graphql errors through your api documentation
* Generate **Client-side** Apollo errors **consumable** like `errorHere(error).isNotAProphetError ?`
* Generate **Client-side** Apollo errors **consumable** like `thisError(error).isNotAProphetError ?`

# 📋 Table of Contents

Expand Down Expand Up @@ -188,20 +188,20 @@ apollo-prophecy ask http://localhost:3000/graphql

#### Helpers

In order to easily handle erros with **Apollo-Client**, the generated `Errors.ts` exposes two helpers methods `errorHere` and `isThis`, both methods takes one paramater of type `ApolloError` or `GraphQLError`.
In order to easily handle erros with **Apollo-Client**, the generated `Errors.ts` exposes two helpers methods `thisError` and `isThis`, both methods takes one paramater of type `ApolloError` or `GraphQLError`.

##### `errorHere()` function
##### `thisError()` function

`errorHere` returns an object that has a **property** named after each errors.
`thisError` returns an object that has a **property** named after each errors.
You can perform a simple `boolean` check on the `error` argument by calling the approiate *key*.

```ts
import { errorHere } from `./_generated/Errors.ts`;
import { thisError } from `./_generated/Errors.ts`;

...(error) => {
if(errorHere(error).isUserNotFoundError){
if(thisError(error).isUserNotFoundError){
// Do something
} else if(errorHere(error).isNotAProphetError){
} else if(thisError(error).isNotAProphetError){
// Do something else
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/ask/createRawFileFromEntries.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/commands/ask/createRawFileFromEntries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const findCodes = (error: ApolloError | GraphQLError): PropheticErrorCode[] => {
return [PropheticErrorCode.CodeLessError];
}

export const errorHere = (error: ApolloError | GraphQLError | undefined ) => {
export const thisError = (error: ApolloError | GraphQLError | undefined ) => {
if(!error) {
return new PropheticError([]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ask/createRawFileFromEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const findCodes = (error: ApolloError | GraphQLError): PropheticErrorCode[] => {
return [PropheticErrorCode.CodeLessError];
}

export const errorHere = (error: ApolloError | GraphQLError | undefined ) => {
export const thisError = (error: ApolloError | GraphQLError | undefined ) => {
if(!error) {
return new PropheticError([]);
}
Expand Down