I need to create a custom directive on INPUT_FIELD_DEFINITION to check if the provided value of the enum isn't being changed to the previous "state" (business logic is that states must go UNAPPROVED - > APPROVED -> CANCELLED -> FULFILLED) but can't quite figure out how to map values in constructor of the enum type.
All my code is available at github
I'm using nextJs backend functionality with neo4j database that generates resolvers for whole schema.
// order Schema
export const order = gql`
type Order {
id: ID! @id
state: OrderState!
user: User! @relationship(type: "MADE", direction: IN)
createdAt: DateTime! @timestamp(operations: [CREATE])
products: [Product!] @relationship(type: "INCLUDE", direction: OUT)
}
enum OrderState {
UNAPPROVED
APPROVED
CANCELLED
FULFILLED
}
`;
export const extendOrder = gql`
extend input OrderCreateInput {
state: OrderState!
}
`;
I want to create @checkState directive that would check if the updating state is valid
I used as a base example from GraphQL Tools docs but it's with string values. I would much appreciate any help.