neo4j-graphql-js
neo4j-graphql-js copied to clipboard
@relation on type does not respect non-nullable marks
Unfortunately these two definitions do not produce the same schema:
type A {
uuid: ID!
bs: [B!]! @relation(name: "HAS_B", direction: OUT)
}
type B {
uuid: ID!
as: [A!]! @relation(name: "HAS_B", direction: OUT)
}
vs
type A {
uuid: ID!
bs: [HasB!]! # ignored
}
type B {
uuid: ID!
as: [HasB!]! # ignored
}
type HasB @relation(name: "HAS_B") {
from: A
to: B
}
In the later, the non-nullable marks !
are ignored. So when using tools like graphql-codegen
you will get
export type Maybe<T> = T | null;
export type A = {
__typename?: 'A';
uuid: Scalars['ID'];
bs?: Maybe<Array<Maybe<_ABs>>>; // should be `bs: Array<_ABs>`
_id?: Maybe<Scalars['String']>;
};
export type _ABs = {
__typename?: '_ABs';
B?: Maybe<B>; // this is also weird, should be `B: B`
};
And that is a pain to access with strict mode TypeScript...
https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608