Apollo Query with Variable
问题 Just a basic apollo query request this.client.query({ query: gql` { User(okta: $okta){ id } }` }).then(result => { this.setState({userid: result.data.User}); console.log(this.state.userid.id) }).catch(error => { this.setState({error: <Alert color="danger">Error</Alert>}); }); The question is, how/where to set the $okta variable. Didn't find a solution on Stackoverflow or Google - would be great if someone could help me:) 回答1: It should be something like this: const query = gql` query User(