graphqlgen
graphqlgen copied to clipboard
Referenced 'AssetCreateManyInput' populating with the wrong types
Description
I have a custom mutation to create an Account with the option to simultaneously create or connect existing Assets to be bound to that Account. I provide a parameter in my mutation function called 'assets' that has a type of AssetCreateManyInput (which should be imported from my generated prisma.graphql schema). Generating the interfaces from my schema.graphql gives the wrong property types for AssetCreateManyInput.
Steps to reproduce
I have these types in my schema.graphql, that reflect and omit some values from my datamodel.graphql:
type Account {
id: ID!
company: String!
isLockedOut: Boolean
users: [User!]!
assets: [Asset!]!
}
type Asset {
assetId: String!
assetType: AssetType
users: [UserAssetConfig!]!
}
I have a mutation that creates an Account, User, and optionally connects/creates Assets
type Mutation {
createAccount(email: String!, company: String!, accountType: AccountType, assets: AssetCreateManyInput): Account
}
My schema.graphql also imports the generated prisma.graphql file # import * from "./generated/prisma.graphql"
I then run graphql-resolver-codegen interfaces -s src/schema.graphql -o ./src/generated/resolvers.ts
Expected results
In resolvers.ts I expect to see something like what is generated in my prisma-client/index.ts:
export interface AssetCreateManyInput {
create?: AssetCreateInput[] | AssetCreateInput;
connect?: AssetWhereUniqueInput[] | AssetWhereUniqueInput;
}
Actual results
In resolvers.ts I actually see an interface that looks like this:
export interface AssetCreateManyInput {
create: string;
connect: string;
}
This causes type casting issues when I'm trying to write my mutation resolver in Typescript.
Versions
- graphql-resolver-codegen: 0.3.0
- OS name and version: Windows 10
I can confirm this issue exists. I'm using both prisma-binding
and graphqlgen
.
Here's what prisma-binding
generates for me:
export interface TagCreateManyWithoutParentInput {
create?: TagCreateWithoutParentInput[] | TagCreateWithoutParentInput;
connect?: TagWhereUniqueInput[] | TagWhereUniqueInput;
}
export interface TagCreateWithoutParentInput {
value: String;
text: String;
}
and here's what graphqlgen
generates:
export interface TagCreateManyWithoutParentInput {
create: string
connect: string
}
which is incorrect.