簡體   English   中英

Apollo 客戶端:codegen 不會為輸入創建類型

[英]Apollo client:codegen does not create types for inputs

我是 GraphQL 的新手,目前正在我們的 TypeScript React 項目中使用 Apollo Client。 我目前正在嘗試使用client:codegen命令生成類型,但它不包括突變輸入。 這是目前我在package.json中的腳本

"codegen:auth-api": "apollo client:codegen --target typescript --includes=\"./src/graphql/auth-api/**/*.ts\" --outputFlat --endpoint=\"https://frontend-engineer-onboarding-api-thxaa.ondigitalocean.app/graphql\" \"src/types\"",

輸出這個

import { SignUpInput } from "./globalTypes";

// ====================================================
// GraphQL mutation operation: SignUp
// ====================================================

export interface SignUp_signUp {
  __typename: "Authentication";
  token: string;
}

export interface SignUp {
  /**
   * ### Description
   * Sign up a user and get an access token if successful.
   * 
   * ### Error Codes
   * `BAD_USER_INPUT` - Email address already used.
   */
  signUp: SignUp_signUp;
}

export interface SignUpVariables {
  input: SignUpInput;
}

上面的問題是globalTypes.ts應該有如下內容時為空

interface SignUpInput {
...
}

這是我的突變代碼示例

export const SIGN_UP = gql`
  mutation SignUp($input: SignUpInput!) {
    signUp(input: $input) {
      token
    }
  }
`;

有什么我想念的嗎? 我也嘗試過傳遞--passthroughCustomScalars但這只是刪除了自定義標量。 如果我在這里找不到任何答案,我深表歉意,並提前感謝您的幫助。

我最終使用了graphql-codegen,它給了我比apollo cli更多的東西。 僅供參考apollo cli現在已棄用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM