Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StringFilter | string type in WhereInput #78

Closed
rnkhouse opened this issue Jan 13, 2022 · 3 comments
Closed

Add StringFilter | string type in WhereInput #78

rnkhouse opened this issue Jan 13, 2022 · 3 comments
Labels
question Further information is requested

Comments

@rnkhouse
Copy link

File create by prisma-nestjs-graphql:

@InputType()
export class business_usersWhereInput {
    @Field(() => [business_usersWhereInput], {nullable:true})
    AND?: Array<business_usersWhereInput>;
    @Field(() => [business_usersWhereInput], {nullable:true})
    OR?: Array<business_usersWhereInput>;
    @Field(() => [business_usersWhereInput], {nullable:true})
    NOT?: Array<business_usersWhereInput>;
    @Field(() => IntFilter, {nullable:true})
    id?: IntFilter;
    @Field(() => IntFilter, {nullable:true})
    business_id?: IntFilter;
    @Field(() => StringFilter, {nullable:true})
    email?: StringFilter;
    @Field(() => StringFilter, {nullable:true})
    password?: StringFilter;
    @Field(() => StringFilter, {nullable:true})
    first_name?: StringFilter;
    @Field(() => StringFilter, {nullable:true})
    last_name?: StringFilter;
}

For the same table, file created by prisma-client-js:

export type business_usersWhereInput = {
    AND?: Enumerable<business_usersWhereInput>
    OR?: Enumerable<business_usersWhereInput>
    NOT?: Enumerable<business_usersWhereInput>
    id?: IntFilter | number
    business_id?: IntFilter | number
    email?: StringFilter | string
    password?: StringFilter | string
    first_name?: StringFilter | string
    last_name?: StringFilter | string
}

How can I add 2 types (StringFilter | string) in the file generated by prisma-nestjs-graphql?

@unlight
Copy link
Owner

unlight commented Jan 13, 2022

You cant. Graphql input union type is not yet described in specification, and thus not supported by Nest.

@rnkhouse
Copy link
Author

@unlight Thanks for the quick response. Is there any future plan to implement this feature? Also, please let me know if there is any way to convert between types. StringFilter => string and viseversa.

@unlight unlight added the question Further information is requested label Jan 14, 2022
@unlight
Copy link
Owner

unlight commented Jan 14, 2022

Is there any future plan to implement this feature?

It is the question for graphql foundation, they are discussing it around five years graphql/graphql-spec#488, then it must be implemented in nestjs.

You cannot take both graphql types, but you can choose between them, see https://github.com/unlight/prisma-nestjs-graphql#useinputtype

Example:

generator nestjsgraphql {
	useInputType_WhereInput_id = "match:Int"
	useInputType_WhereInput_email = "match:String
}

May generate:

    @Field(() => Int, {nullable:true})
    id?: number;

    @Field(() => String, {nullable:true})
    email?: string;

@unlight unlight closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants