如何解决GraphQL 查询 - 编写架构和解析器
我正在尝试使用 Apollo Server 和 SWAPI API 学习 GraphQL,我正在尝试检索以下人员属性名称、身高、质量、性别、家庭世界。任何人都可以帮助了解架构和解析器的外观吗? 到目前为止,这是我对架构的了解:
export const Map = gql`
type People {
name: String!
height: String!
mass: String!
gender: String!
homeworld: String!
}
type Page {
page: Int
}
type Query {
allPeople: [People!]!
peoplePages(page: Int!): People
personDetails(name: String!): People
}
`;
这是示例数据。我对此很满意,可能会感谢您的帮助
{
"count": 82,"next": "http://swapi.dev/api/people/?page=2","previous": null,"results": [
{
"name": "Luke Skywalker","height": "172","mass": "77","hair_color": "blond","skin_color": "fair","eye_color": "blue","birth_year": "19BBY","gender": "male","homeworld": "http://swapi.dev/api/planets/1/","films": [
"http://swapi.dev/api/films/1/","http://swapi.dev/api/films/2/","http://swapi.dev/api/films/3/","http://swapi.dev/api/films/6/"
],"species": [],"vehicles": [
"http://swapi.dev/api/vehicles/14/","http://swapi.dev/api/vehicles/30/"
],"starships": [
"http://swapi.dev/api/starships/12/","http://swapi.dev/api/starships/22/"
],"created": "2014-12-09T13:50:51.644000Z","edited": "2014-12-20T21:17:56.891000Z","url": "http://swapi.dev/api/people/1/"
},{
"name": "C-3PO","height": "167","mass": "75","hair_color": "n/a","skin_color": "gold","eye_color": "yellow","birth_year": "112BBY","gender": "n/a","http://swapi.dev/api/films/4/","http://swapi.dev/api/films/5/","species": [
"http://swapi.dev/api/species/2/"
],"vehicles": [],"starships": [],"created": "2014-12-10T15:10:51.357000Z","edited": "2014-12-20T21:17:50.309000Z","url": "http://swapi.dev/api/people/2/"
},
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。