I have a graphQL ApolloServer returning a paginated set of Transaction(s) for an Account. Here is a snippet of my schema:
type Account implements Node {
id: ID!
name: String!
}
type Transaction implements Node {
id: ID!
name: String!
accountId: ID!
}
The relay spec https://relay.dev/graphql/connections.htm says the field that returns a connection type can take parameters of either:
1) before
and last
or
2) after
and first
This implies they cannot all be optional without defining a default after
or before
opertation
For a query that handles only the after
case, I would make a required after thus:
type Query {
accounts: [Account]!
transactions(accountId: ID!,after: String!, first: Int = 10 ): TransactionsBelongToAccountConnection
}
But for one that handles both the before
and after
case, I would need to make all four of these parameters optional and declare one of after
or before
modes to be the default:
type Query {
accounts: [Account]!
transactions(accountId: ID!, before: Sting, last: Int = 10, after: String, first: Int = 10 ): TransactionsBelongToAccountConnection
}
or (my question is) in graphql is there a way of making exactly one of two parameters required?