嗨,我正在与angular的graphql客户一起工作。有什么方法可以动态地将查询名称作为变量传递?例如。
query ($filterName: String)($names: String)
(filterName: $filterName)(names: $names) {
name
surname
这是我当前的代码:
this.taxonomyRef = this.apolloTaxonomy.watchQuery<Query>({
query: gql`
query filter($names: String) {
filter(names: $names) {
name
surname
age
address
}
}
`,
variables: { names: this.elements},
fetchResults: false,
fetchPolicy: 'network-only',
});
this.taxonomy = this.taxonomyRef
.valueChanges
.pipe(
map(result => result.data.taxonomy)
);
}