Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Confused by non-optional array types? #106

Open
geelen opened this issue Feb 19, 2022 · 1 comment
Open

Confused by non-optional array types? #106

geelen opened this issue Feb 19, 2022 · 1 comment

Comments

@geelen
Copy link

geelen commented Feb 19, 2022

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

@timkendall
Copy link
Owner

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[];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants