I am new to GraphQL and is currently using Apollo Client on our TypeScript React project. I am currently trying to generate types using client:codegen
command and it is not including the Inputs on Mutations. This is currently the script I have in my 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\"",
That outputs this
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;
}
The problem above is that globalTypes.ts
is empty when it should have something like below
interface SignUpInput {
...
}
This is a sample of my mutation code
export const SIGN_UP = gql`
mutation SignUp($input: SignUpInput!) {
signUp(input: $input) {
token
}
}
`;
Is there something I am missing? I've also tried passing --passthroughCustomScalars
but that just removes custom scalars. I apologize if I could not find any answer here on SO and Thanks in advance for your help.
I ended up using graphql-codegen which gives me more than what apollo cli
can. And FYI apollo cli
is now deprecated.