[英]How to avoid circular dependency in angular project with Apollo client and `graphql-codegen` when importing types in client resolver?
[英]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.