Skip to content
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

Upgrade Apollo server to v4 #8036

Merged
merged 22 commits into from
Nov 26, 2024
Merged

Upgrade Apollo server to v4 #8036

merged 22 commits into from
Nov 26, 2024

Conversation

rikukissa
Copy link
Member

@rikukissa rikukissa commented Nov 21, 2024

Our previous version had lost support. I also want to upgrade so that we can use API federation for new events APIs :)

@rikukissa rikukissa added the 🚀 Ready to deploy Deployment automation should pick this PR up and start auto-deploying it label Nov 21, 2024
Copy link

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 21, 2024 09:22 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to upgrade-apollo-to-4 November 21, 2024 09:22 Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 21, 2024 13:32 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 21, 2024 13:40 — with GitHub Actions Inactive
@rikukissa rikukissa marked this pull request as ready for review November 21, 2024 13:41
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 21, 2024 13:41 — with GitHub Actions Inactive
@rikukissa rikukissa changed the title Upgrade Apollo Upgrade Apollo server to v4 Nov 21, 2024
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 22, 2024 06:45 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 22, 2024 06:47 — with GitHub Actions Inactive
packages/gateway/src/features/fhir/FHIRAPI.ts Show resolved Hide resolved
}

getPatient(id: string) {
const inBundle = getResourceFromBundleById(this.context.record, id)
const inBundle = getResourceFromBundleById(this.context.record!, id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are trying to get the resource, then shouldn't it be findResource...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is even used anywhere 😄 This would throw an error if there isn't a patient which to me seems logical given the method is named getPatient. So will give you a patient with you know their id or else throw an error

Comment on lines +29 to +38
class RateLimitError extends GraphQLError {
constructor(message = 'You are being rate limited') {
super(message, {
extensions: {
code: 'DAILY_QUOTA_EXCEEDED',
http: {
status: 429
}
}
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! This should make the graphql requests actually fail by responding with something other than 200 right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is potential for that but I need to test how it works 👍

Comment on lines 43 to 46
getUser: async (_, { userId }, { dataSources }) => {
const user = await dataSources.usersAPI.getUserById(userId!)
return user
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we intentionally removing the rate limit from this endpoint?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, good catch! I removed it while debugging something

@@ -39,11 +34,11 @@ export class UsersAPI extends RESTDataSource {
}

try {
const response = this.post('getUser', { email })
const response = await this.post('getUser', { body: { email } })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't want to await here as that would just break the caching functionality. We want to cache the Promise in this case and not the Resolved value so that when multiple requests are made, we can just return the cached Promise that we created on the first request

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for the other requests in this file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool yea, I was wondering about that.. Makes sense!

Copy link
Collaborator

@makelicious makelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Comments are mostly stylistic, check the code suggestion whether it is needed at least.

this.baseURL = `${FHIR_URL}/DocumentReference`
}
const fhirPath = parse(FHIR_URL).path || ''
export default class DocumentsAPI extends OpenCRVSRestDataSource {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we capitalise CRVS, API and others, maybe rest could be also capitalised.

}

getPatient(id: string) {
const inBundle = getResourceFromBundleById(this.context.record, id)
const inBundle = getResourceFromBundleById(this.context.record!, id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could assertion be managed by types?

packages/gateway/src/features/fhir/paymentsAPI.ts Outdated Show resolved Hide resolved
packages/gateway/src/features/user/root-resolvers.ts Outdated Show resolved Hide resolved
packages/gateway/src/features/fhir/documentsAPI.ts Outdated Show resolved Hide resolved
packages/gateway/src/features/fhir/documentsAPI.ts Outdated Show resolved Hide resolved
packages/gateway/src/features/fhir/FHIRAPI.ts Outdated Show resolved Hide resolved
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 22, 2024 07:27 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 22, 2024 08:12 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 08:40 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 08:54 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 08:58 — with GitHub Actions Inactive
@ocrvs-bot
Copy link
Collaborator

Your environment is deployed to https://upgrade-apollo-to-4.opencrvs.dev

@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 09:26 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 12:43 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 12:47 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 13:14 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 14:06 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 14:40 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 25, 2024 14:41 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 26, 2024 09:00 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 26, 2024 09:23 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to upgrade-apollo-to-4 November 26, 2024 09:27 — with GitHub Actions Inactive
@rikukissa rikukissa deployed to upgrade-apollo-to-4 November 26, 2024 09:32 — with GitHub Actions Active
@rikukissa rikukissa merged commit cb97021 into develop Nov 26, 2024
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Ready to deploy Deployment automation should pick this PR up and start auto-deploying it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants