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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...