Skip to content

Instantly share code, notes, and snippets.

@DogAndHerDude
Last active April 20, 2021 07:42
Show Gist options
  • Save DogAndHerDude/2db5e38271bfd78d84fded48bcd543d9 to your computer and use it in GitHub Desktop.
Save DogAndHerDude/2db5e38271bfd78d84fded48bcd543d9 to your computer and use it in GitHub Desktop.
Pass vars to template string
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