Created
October 20, 2023 20:16
-
-
Save mrajaeim/2fd75eec878c9f6d014b631b9de6d32f to your computer and use it in GitHub Desktop.
How to not delete @client directive for mocking gql from codes in Apollo client!
This file contains hidden or 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
| import { gql as apolloGql } from "@apollo/client"; | |
| const gql = (strings, ...keys) => { | |
| if ( | |
| process.env.NODE_ENV === "test" || | |
| process.env.NODE_ENV === "production" | |
| ) { | |
| strings = strings.map((str) => | |
| str.replace(/\@client\s/gi, "").replace(/\s\@client/gi, ""), | |
| ); | |
| } | |
| return apolloGql(strings, ...keys); | |
| }; | |
| export default gql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment