Let's say I have
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="trade_id")
int tradeId;
When I query this from the database, I will want to get the tradeId. However, when performing a Create, obviously I won't have the tradeId, since the Database is going to generate it when I insert it.
input TradeInput {
tradeId: Int!
...
But the schema SPQR is generating for me is setting this field to Not Null, however.
So my question is, how can prevent this field from automatically coming up as Not Null, so I won't have to send it down on Creates, but can retrieve it.
An
int
simply can not benull
. But you have a few options:ID
scalar type (using@GraphQLId
) instead of anInt
@GraphQLInputField
Integer
instead ofint
, asInteger
is nullable