gpt4 book ai didi

ios - 安装GraphQL iOS框架

转载 作者:行者123 更新时间:2023-12-01 16:02:08 26 4
gpt4 key购买 nike

我想将apollo框架添加到我的iOS项目中。我正在关注documentation但无法构建它。

  • 我通过cocoapods安装了阿波罗
  • 我向目标添加了代码生成构建步骤(将其置于编译源上方...)
  • 我通过apollo模式下载了该模式:download --endpoint = http://localhost:4000/graphql schema.json。我将schema.json文件添加到项目的根目录中。
  • 我构建了它并得到以下错误:
  • apollo@1.2.0
    在20.385秒内添加416程序包
    ++ exec /Users/PATH/node_modules/.bin/apollo codegen:generate --queries = --schema = schema.json API.swift
    ›警告:阿波罗更新从1.2.0到1.7.0
    错误:标记-查询期望值为
    命令/ bin / sh失败,退出代码为2

  • 我的 schema.grapqhl 文件如下所示:
    type Query {
    """ User """
    users: [User!]!
    user(username: String!): User

    """ Question """
    questions: [Question!]!
    question(id: Int!): Question

    }

    type Mutation {
    """ User """
    createUser(username: String!): User
    updateUser(username: String!, newUsername: String!): [Int!]!
    deleteUser(username: String!): Int!

    """ Question """
    createQuestion(text: String!, category: Int!, active: Boolean!):
    Question
    updateQuestion(id: Int!, text: String!, category: Int!, active: Boolean!): [Int!]!
    deleteQuestion(id: Int!): Int!
    }

    type Subscription {
    answerAdded: Answer
    }

    type Question {
    id: Int!
    text: String!
    categoryId: QuestionCategory!
    active: Boolean!
    createdAt: String!
    updatedAt: String!
    }
    ......

    似乎查询参数没有输入:
    阿波罗代码生成:生成--queries = --schema = schema.json API.swift

    如果我自己通过终端尝试
    apollo codegen:generate --queries=schema.graphql --schema=schema.json API.swift

    我收到以下错误:
    Warning: apollo update available from 1.2.0 to 1.7.0
    .../schema.graphql: The Query definition is not executable.
    .../schema.graphql: The Mutation definition is not executable.
    .../schema.graphql: The Subscription definition is not executable.
    .../schema.graphql: The Question definition is not executable.
    ... some more ...
    :heavy_check_mark: Scanning for GraphQL queries (1 found)
    :heavy_check_mark: Loading GraphQL schema
    :heavy_check_mark: Parsing GraphQL schema
    :heavy_multiplication_x: Generating query files with 'swift' target
    → Validation of GraphQL query document failed
    ToolError: Validation of GraphQL query document failed
    at Object.validateQueryDocument
    ....

    您能帮我找出为什么我无法构建该项目吗?是否因为我的schema.graphl文件错误?

    最佳答案

    由@Sergej Birklin回答,我想与您分享另一个查询-

    Profile.graphql

    query MyProfile{
    player {
    me {
    id
    secret
    name
    email
    state
    country
    timezone
    picture
    pictureType
    audio
    rank
    }
    }
    }

    就像我们只是查询我的个人资料信息(我是 播放器类型)一样,查询将返回我需要的信息,例如我的ID,姓名,电子邮件,状态等。

    如您所述,它将创建MyProfileQuery

    希望这对您有帮助

    #swith #GraphQL #iOS

    关于ios - 安装GraphQL iOS框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51822864/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com