admin管理员组文章数量:1420166
So I am running a gql query on a React app and passing some default variables. But when the query runs I'm getting this error:
Error: GraphQL error: Validation error of type FieldUndefined: Field 'firstname' in type 'HealthcareWorkersPage' is undefined @ 'healthcareWorkers/firstname'
This is the query in the .js file :
export const GET_PROFILES = gql`query healthcareWorkers($pageNo: Int = 0, $pageSize:Int = 6) {
healthcareWorkers(pageNo: $pageNo, pageSize: $pageSize) {
firstname
}
}`;
Earlier the above query was :
export const GET_PROFILES = gql`query {
healthcareWorkers($pageNo: Int = 0, $pageSize:Int = 6) {
healthcareWorkers(pageNo: $pageNo, pageSize: $pageSize) {
firstname
}
}
}`;
Notice the {}
after the query keyword. But in this case I got an error saying Syntax Error: Expected Name, found $
I use this query on the playground and it works without any issues:
query{
healthcareWorkers(pageNo: 1, pageSize:6) {
healthcareWorkers {
firstname
}
}
}
The healthcareWorkers Schema:
So I am running a gql query on a React app and passing some default variables. But when the query runs I'm getting this error:
Error: GraphQL error: Validation error of type FieldUndefined: Field 'firstname' in type 'HealthcareWorkersPage' is undefined @ 'healthcareWorkers/firstname'
This is the query in the .js file :
export const GET_PROFILES = gql`query healthcareWorkers($pageNo: Int = 0, $pageSize:Int = 6) {
healthcareWorkers(pageNo: $pageNo, pageSize: $pageSize) {
firstname
}
}`;
Earlier the above query was :
export const GET_PROFILES = gql`query {
healthcareWorkers($pageNo: Int = 0, $pageSize:Int = 6) {
healthcareWorkers(pageNo: $pageNo, pageSize: $pageSize) {
firstname
}
}
}`;
Notice the {}
after the query keyword. But in this case I got an error saying Syntax Error: Expected Name, found $
I use this query on the playground and it works without any issues:
query{
healthcareWorkers(pageNo: 1, pageSize:6) {
healthcareWorkers {
firstname
}
}
}
The healthcareWorkers Schema:
Share Improve this question asked May 13, 2020 at 9:03 krishnanspacekrishnanspace 4331 gold badge7 silver badges18 bronze badges1 Answer
Reset to default 1firstname
field lives inside healthcareWorkers
type. Try this query:
export const GET_PROFILES = gql`
query healthcareWorkers($pageNo: Int = 0, $pageSize: Int = 6) {
healthcareWorkers(pageNo: $pageNo, pageSize: $pageSize) {
healthcareWorkers {
firstname
}
}
}
`;
本文标签: javascriptGraphql saying Validation error of type undefinedStack Overflow
版权声明:本文标题:javascript - Graphql saying Validation error of type undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745325331a2653565.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论