-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Events v2: Skeleton GraphQL resolvers for basic operations #8033
Changes from all commits
1b7d031
9f83721
f259bc3
d2a03f8
5d1351f
a05906d
68f8adb
a9f98a9
7914c63
81f470f
d8addb9
55a2d63
1f90403
269970d
e8add12
307a04f
d31792f
a5e2c8d
e04fef8
d031ed5
6d7b57b
c3c97ac
c604312
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,7 @@ | |
"xregexp": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@opencrvs/gateway": "^1.5.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does the client need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does now as I added the logic to look at workflow dependencies to figure out which packages cannot be optimised away in build and test processes. Client did seem to have a dependency to gateway for whatever reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to find the dependency but couldn't :O |
||
"@graphql-codegen/add": "^5.0.0", | ||
"@graphql-codegen/cli": "^5.0.0", | ||
"@graphql-codegen/introspection": "^3.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,6 @@ export const ActionConfig = z.object({ | |
}) | ||
|
||
export const ActionInputBase = z.object({ | ||
type: z.enum(actionTypes as NonEmptyArray<ActionType>), | ||
fields: z.array( | ||
z.object({ | ||
id: z.string(), | ||
|
@@ -62,18 +61,28 @@ export const ActionInputBase = z.object({ | |
) | ||
}) | ||
|
||
export const ActionInput = z.union([ | ||
ActionInputBase.extend({ | ||
type: z.enum([ActionType.CREATE]) | ||
}), | ||
ActionInputBase.extend({ | ||
type: z.enum([ActionType.REGISTER]), | ||
identifiers: z.object({ | ||
trackingId: z.string(), | ||
registrationNumber: z.string() | ||
}) | ||
export const CreateActionInput = ActionInputBase.extend({}) | ||
export const NotifyActionInput = ActionInputBase.extend({}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment for this pattern? Is it a matter of taking copy of the base an separating the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
export const DeclareActionInput = ActionInputBase.extend({}) | ||
export const RegisterActionInput = ActionInputBase.extend({ | ||
identifiers: z.object({ | ||
trackingId: z.string(), | ||
registrationNumber: z.string() | ||
}) | ||
]) | ||
}) | ||
|
||
export const ActionInput = z | ||
.union([ | ||
CreateActionInput.extend({ type: z.enum([ActionType.CREATE]) }), | ||
NotifyActionInput.extend({ type: z.enum([ActionType.NOTIFY]) }), | ||
DeclareActionInput.extend({ type: z.enum([ActionType.DECLARE]) }), | ||
RegisterActionInput.extend({ type: z.enum([ActionType.REGISTER]) }) | ||
]) | ||
.and( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there semantic difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .and apparently creates https://zod.dev/?id=merge (merge is equivalent to extend but has better example :D) |
||
z.object({ | ||
createdBy: z.string() | ||
}) | ||
) | ||
|
||
export type ActionInput = z.infer<typeof ActionInput> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,25 +16,7 @@ import { Label, Summary } from './utils' | |
* A subset of an event. Describes fields that can be sent to the system with the intention of either creating or mutating a an event | ||
*/ | ||
export const EventInput = z.object({ | ||
type: z.string(), | ||
fields: z.array( | ||
z.object({ | ||
id: z.string(), | ||
value: z.union([ | ||
z.string(), | ||
z.number(), | ||
z.array( | ||
// @TODO: Check if we could make this stricter | ||
z.object({ | ||
optionValues: z.array(z.string()), | ||
type: z.string(), | ||
data: z.string(), | ||
fileSize: z.number() | ||
}) | ||
) | ||
]) | ||
}) | ||
) | ||
type: z.string() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only field the user can really send at the point of Event creation is |
||
}) | ||
export type EventInput = z.infer<typeof EventInput> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could benefit from adding description for this documenting the reason/aim