如何在URQL中通过PK检索
我有一个 URQL GraphQL 查询,它根据主键字段 (id) 检索单个元组。我在指定查询所需的语法方面遇到问题。我正在使用 graphql-codegen 生成的“useQuery”挂钩。
GetOneOrgUnit.query.gql
query GetOneOrgUnit($id: uuid!) {
OrgUnit_by_pk(id: $id) {
id
name
parent_orgunit
}
}
我的 Vue 3 代码是:
<script setup lang="ts2>
import { useGetOneOrgUnitQuery } from '@/generated/graphql'
const props = defineProps({
id: {
type: String,
required: true
}
})
const variables = {
id: props.id
}
const result = useGetOneOrgUnitQuery(variables)
Typescript 抱怨最后一个语句中传递的“变量”参数。收到的消息是:
const variables: {
id: string;
}
Type '{ id: string; }' has no properties in common with type 'Omit<UseQueryArgs<never, Exact<{ id: string; }>>, "query">'.ts(2559)
我需要在这里做什么?
提前致谢。
I have an URQL GraphQL query which retrieves a single tuple based on the primary key field (id). I am having trouble with the syntax required to specify the query. I am using a'useQuery' hook generated by graphql-codegen.
GetOneOrgUnit.query.gql
query GetOneOrgUnit($id: uuid!) {
OrgUnit_by_pk(id: $id) {
id
name
parent_orgunit
}
}
My Vue 3 code is:
<script setup lang="ts2>
import { useGetOneOrgUnitQuery } from '@/generated/graphql'
const props = defineProps({
id: {
type: String,
required: true
}
})
const variables = {
id: props.id
}
const result = useGetOneOrgUnitQuery(variables)
Typescript complains about the 'variables' parameter being passed in the last statement. The message received is:
const variables: {
id: string;
}
Type '{ id: string; }' has no properties in common with type 'Omit<UseQueryArgs<never, Exact<{ id: string; }>>, "query">'.ts(2559)
What do I need to do here?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯 - 简单
我只需要将“变量”对象括在 {} 中,
这样
就变成了
Hmm - Simple
I just needed to enclose 'variables' object in {}
so
became