Last active
November 9, 2021 16:19
-
-
Save rcdexta/d2a7b3859e807abdc955155128e5cf38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function ApolloMockedProvider(props: any) { | |
let { mocks, ...otherProps } = props; | |
let mockLink = new MockLink(mocks); | |
let errorLoggingLink = onError(({ networkError }) => { | |
if (networkError) { | |
/No more mocked responses for the query/.test(networkError.message); | |
console.warn(`[Network error]: ${networkError}`); | |
} | |
}); | |
let link = ApolloLink.from([errorLoggingLink, mockLink]); | |
return <MockedProvider {...otherProps} link={link} />; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage: