Graphql 是否忽略使用apollo客户端进行变异查询的结果?
我想使用graphql在服务器上触发Graphql 是否忽略使用apollo客户端进行变异查询的结果?,graphql,apollo-client,Graphql,Apollo Client,我想使用graphql在服务器上触发addLicenseCodeOneTimeUsage操作。我不知道服务器将响应什么,也不需要任何响应。如您所见,我在addLicenseCodeOneTimeUsage{}中没有列出任何属性 const client = new ApolloClient({ link: link, cache: new InMemoryCache(), }); yield client.mutate({ /* tslint:disable */
addLicenseCodeOneTimeUsage
操作。我不知道服务器将响应什么,也不需要任何响应。如您所见,我在addLicenseCodeOneTimeUsage{}
中没有列出任何属性
const client = new ApolloClient({
link: link,
cache: new InMemoryCache(),
});
yield client.mutate({
/* tslint:disable */
mutation: gql`
}
mutation licensemutation($distributor: String!, $licenceType: String!, $duration: String!, $userId: String!) {
addLicenseCodeOneTimeUsage(distributor: $distributor, licenseType: $licenseType, duration: $duration, userId: $userId) {
}
}
`,
/* tslint:enable */
variables: {
userId: username,
distributor: distributor,
licenseType: licenseType,
duration: duration,
},
});
- 到目前为止,我写的东西听起来合理吗?或者我对graphql的工作原理或者应该如何使用有明显的误解吗
- 在graphql字符串中,我没有定义要接收的信息。该语法有效吗?还是我需要明确声明我要忽略结果
如果您同时控制服务器和客户机,而变异实际上什么也不返回,那么您可以定义一个人工
ok:Boolean代码>这总是正确的。您可能会返回类似于用户对象的东西,其中也包含一个权利列表,在这种情况下,您可以选择(并忽略)用户ID。我想这可能就是它的用途
ignoreResults
-如果为true,则返回的数据属性不会随突变结果更新
因此,突变(使用此选项)看起来像:
client.mutate({
mutation: MutationDocument
variables: {
userId: username,
distributor: distributor,
licenseType: licenseType,
duration: duration,
},
ignoreResults: true
});