@ apollo / federation对文档中的示例抛出错误

时间:2019-07-03 00:00:25

标签: graphql apollo apollo-server apollo-federation

遇到一个问题,我自己尝试尝试后,我尝试了文档中的示例,然后遇到了一个类似的问题,文档是否错误,或者我做的是愚蠢的事情?

我要执行的示例是此页面上的示例:https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https

相关的代码段是:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    Purchases.shared.purchaserInfo { (purchaserInfo, error) in
        self.configurePurchases(purchaserInfo: purchaserInfo)
    }
}

func configurePurchases(purchaserInfo: PurchaserInfo?) {
    if let purchaserInfo = purchaserInfo {
        if purchaserInfo.activeEntitlements.contains("myKillerFeatureEntitlement") {
            myButton.setTitle("Subscribed",for: .normal)
            labelAutoTaxDescription.text = "You are currently subscribed. Thank you for your support."

            let dateFormatter = DateFormatter()
            dateFormatter.dateStyle = .medium
            dateFormatter.timeStyle = .medium

            if let expirationDate = purchaserInfo.expirationDate(forEntitlement: "myKillerFeatureEntitlement") {
                self.labelAutoTaxDetectionPrice.text = "Expiration Date: \(dateFormatter.string(from: expirationDate))"
            }
        }
    }

    // Here is where I need check if it's a returning user so I can change the name of the button
    if isReturningUser{

        myButton.setTitle("Renew",for: .normal)

        // other code
    }
}

请注意,我故意将解析器留空,我只是在尝试编译模式。

这是我得到的错误:

const server = new ApolloServer({
  schema: buildFederatedSchema([{
    typeDefs: gql`
      extend type Query {
        me: User
      }

      type User @key(fields: "id") {
        id: ID!
        username: String!
      }
    `,
    resolvers: [],
  }, {
    typeDefs: gql`
      extend type Query {
        topProducts(first: Int = 5): [Product]
      }

      type Product @key(fields: "upc") {
        upc: String!
        name: String!
        price: Int
      }
    `,
    resolvers: [],
  }, {
    typeDefs: gql`
      type Review {
        body: String
        author: User @provides(fields: "username")
        product: Product
      }

      extend type User @key(fields: "id") {
        id: ID! @external
        reviews: [Review]
      }

      extend type Product @key(fields: "upc") {
        upc: String! @external
        reviews: [Review]
      }
    `,
    resolvers: [],
  }]),
  context: ({ req }) => ({ user: req.user }),
})

有人可以帮我吗?

0 个答案:

没有答案