[英]NodeJs GraphQL fragments resolver
Its my example.它的我的例子。 am trying fragment .我正在尝试片段。 am not sure how will i connect fragment to resolver.我不确定我将如何将片段连接到解析器。 Can anyone help me?谁能帮我? https://launchpad.graphql.com/9qvqz3v5r https://launchpad.graphql.com/9qvqz3v5r
If i query as below如果我查询如下
{
user {
userId
firstName
lastName
pincode
state
country
}
}
I will get this output JSON我会得到这个输出 JSON
{
"data": {
"user": {
"userId": 4,
"firstName": "Priya",
"lastName": "zzz",
"pincode": "600021",
"state": "TN",
"country": "INDIA"
}
}
}
I need Same output if i query using fragment.如果我使用片段查询,我需要相同的输出。
{
user {
userId
firstName
lastName
addressDetails
}
}
You can use fragment query like this, which returns same result您可以像这样使用片段查询,它返回相同的结果
{
user{
... userPayload
}
}
fragment userPayload on User{
userId
firstName
lastName
pincode
state
country
}
I think this is the one you want我想这是你想要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.