tql
tql copied to clipboard
Confused by non-optional array types?
With this input:
input CreateUserInput {
username: String!
email: String!
avatar: String
posts_ref: [ID!]!
}
input UpdateUserInput {
email: String
avatar: String
posts_ref: [ID!]
}
I get this output:
export interface CreateUserInput {
readonly username: string;
readonly email: string;
readonly avatar?: string;
readonly posts_ref: string; // <- error here
}
export interface UpdateUserInput {
readonly email?: string;
readonly avatar?: string;
readonly posts_ref?: string[];
}
Something about posts_ref
being non-optional? Not sure if this is fixed in the v1 rc, I'm still using 0.8.0
Yep this is fixed in the latest RC. At this point I would recommend switching to it if you can (let me know if there is anything preventing you from doing so and I can help).
Here's the output from running npx @timkendall/tql-gen <schema>
:
export interface ICreateUserInput {
username: string;
email: string;
avatar?: string;
posts_ref: string[];
}
export interface IUpdateUserInput {
email?: string;
avatar?: string;
posts_ref?: string[];
}