graphql-engine
graphql-engine copied to clipboard
actions typescript codegen produces types with incorrect underscores
Just trying out actions and liking it a lot so far! I am running a typescript/koa backend to serve the actions and noticed you have type definitions under typescript-zeit so decided to incorporate this! However it looks like the types are malformed with strange underscores that are not mirrored in the handler code.
initialize_team.ts
import { NowRequest, NowResponse } from '@now/node';
import { MutationInitializeTeamArgs } from './hasuraCustomTypes';
import fetch from "node-fetch"
// Request Handler
const handler = async (req: NowRequest, res: NowResponse) => {
// get request input
const { userId, name, description }: MutationInitializeTeamArgs = req.body.input;
// run some business logic
/*
// In case of errors:
return res.status(400).json({
message: "error happened"
})
*/
// success
return res.json({
affected_rows: "<value>"
})
}
export default handler;
hasuraCustomTypes.ts
export type Maybe<T> = T | null;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
export type InitializeTeamOutput = {
__typename?: 'InitializeTeamOutput';
affected_rows: Scalars['Int'];
};
export type Mutation = {
__typename?: 'Mutation';
initialize_team?: Maybe<InitializeTeamOutput>;
};
export type MutationInitialize_TeamArgs = {
userId: Scalars['Int'];
name: Scalars['String'];
description?: Maybe<Scalars['String']>;
};
Notice the strange underscores in the types. I am running v1.2.0-beta.3
Hey @mikyoengine ! Yes it is a bug. Thanks for reporting :)