Last active
April 20, 2021 07:42
-
-
Save DogAndHerDude/2db5e38271bfd78d84fded48bcd543d9 to your computer and use it in GitHub Desktop.
Pass vars to template string
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
import { ApolloClient, InMemoryCache, gql } from '@apollo/client'; | |
const client = new ApolloClient({ | |
cache: new InMemoryCache(), | |
url: 'https://staging.reneza.com/api' | |
}); | |
client.query({ | |
query: gql` | |
query($email: String!, $password: String!) { | |
login(email: $email, password: $password) { | |
... | |
} | |
} | |
`, | |
variables: { | |
email: '...', | |
password: '...', | |
}, | |
}); | |
function getLoginQuery(email: string, password: string): string { | |
return ` | |
query { | |
login(email: ${email}, password: ${password}) { | |
... | |
} | |
} | |
`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment