-
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
Conversation
…into ocrvs-7824-b
Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:
|
@@ -3,7 +3,8 @@ | |||
"skipLibCheck": true, | |||
"baseUrl": "./src", | |||
"paths": { | |||
"@gateway/*": ["./*"] | |||
"@gateway/*": ["./*"], | |||
"@events/*": ["../../events/src/*"] |
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.
This is a little nasty – it is because gateway imports the appRouter
from events
import type { AppRouter } from '@opencrvs/events/src/router'
which again imports modules inside Events with the @events/...
paths.
❯ yarn test:compilation
yarn run v1.22.4
$ tsc --noEmit
../events/src/service/events.ts:12:27 - error TS2307: Cannot find module '@events/storage/mongodb' or its corresponding type declarations.
12 import { getClient } from '@events/storage/mongodb'
~~~~~~~~~~~~~~~~~~~~~~~~~
]) | ||
}) | ||
) | ||
type: z.string() |
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.
The only field the user can really send at the point of Event creation is type
if we take on the approach of only submitting actions like registerEvent(eventId, registrationData)
from the client
url: env.EVENTS_URL, | ||
transformer: superjson, | ||
headers({ opList }) { | ||
const headers = opList[0].context?.headers |
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.
Not at all happy about this. opList is a non-empty list but still..
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.
Could we parse it and throw to be sure, have a default or acknowledge the possibly undefined?
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.
a bit wonky that the opList cannot be strictly typed :/ but yeah works like this or !
with a comment or ^
1412548
to
2a46d72
Compare
…into ocrvs-7824-b
8943b95
to
375acd1
Compare
375acd1
to
d12e766
Compare
d12e766
to
269970d
Compare
0d0a79f
to
43b1146
Compare
43b1146
to
e8add12
Compare
8e12154
to
a5e2c8d
Compare
Your environment is deployed to https://ocrvs-7824-b.opencrvs.dev |
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.
Looks good! Non functional comments
if (obj.type === ActionType.REGISTER) { | ||
return 'RegisterAction' | ||
} | ||
return 'CreateAction' |
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 might want to be explicit here e.g. not defaulting to anything but exhausting the options
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.
could we do type satisfies never
to make sure all cases are handled at the end
url: env.EVENTS_URL, | ||
transformer: superjson, | ||
headers({ opList }) { | ||
const headers = opList[0].context?.headers |
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.
Could we parse it and throw to be sure, have a default or acknowledge the possibly undefined?
@@ -29,6 +29,7 @@ export const env = cleanEnv(process.env, { | |||
APPLICATION_CONFIG_URL: url({ devDefault: 'http://localhost:2021/' }), | |||
NOTIFICATION_URL: url({ devDefault: 'http://localhost:2020/' }), | |||
WORKFLOW_URL: url({ devDefault: 'http://localhost:5050/' }), | |||
EVENTS_URL: url({ devDefault: 'http://localhost:5555/' }), |
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.
Opinion: Since we are using both conventions, with and without trailing slash, I would opt for without when introducing new ones. What do you think?
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.
I agree; an extra trailing slash in our current setup might convey to a newcomer that it has a meaning that it doesn't
.mutation(async (options) => { | ||
return addAction(options.input.eventId, { | ||
...options.input.action, | ||
type: 'NOTIFY', |
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.
Using these through the ActionType.NOTIFY
will make changing them much easier in the future.
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 comment
The 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 type
extension?
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.
RegisterActionInput.extend({ type: z.enum([ActionType.REGISTER]) })
since one could argue that this is not RegisterActionInput
until it has the type
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Is there semantic difference between extend
and and
?
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.
.and apparently creates { name: string } & { age: number }
while .extend creates { name: string; age: number }
https://zod.dev/?id=merge (merge is equivalent to extend but has better example :D)
vs
https://zod.dev/?id=and
@@ -85,17 +85,36 @@ jobs: | |||
with: | |||
node-version-file: .nvmrc | |||
|
|||
- name: Extract dependencies for ${{ matrix.package }} |
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
@@ -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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to find the dependency but couldn't :O
Country config: opencrvs/opencrvs-countryconfig#328