-
Notifications
You must be signed in to change notification settings - Fork 69
feat: confirm registration via graphql api #288
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
31af83d
refactor: remove all graphql related stuff
naftis 858e0c7
chore: remove unused code
naftis 9c90e71
feat: allow graphql type hints
naftis 0053906
feat: allow confirming registration via the new graphql api
naftis 7ee30bf
refactor: use graphql comment so no package needed
naftis 2b9e238
refactor: use graphql comment in the last query as well
naftis 1dac6e8
refactor: throw if the composition doesn't have an id
naftis e520ffc
fix: throw if the id is not found as the function is _get_
naftis 812e31a
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig …
naftis 444d99b
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig …
naftis 9d6f83d
fix: add required env variables
naftis 432ee7c
fix: use identifiers instead of childIdentifiers
naftis 607de76
fix: remove posting tracking id
naftis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ data | |
|
|
||
| .history | ||
|
|
||
| graphql.schema.json | ||
| *.tar.gz | ||
| .secrets | ||
| .env* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "recommendations": [ | ||
| "apollographql.vscode-apollo" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "client": { | ||
| "service": { | ||
| "name": "@opencrvs/gateway", | ||
| "url": "http://localhost:7070/graphql" | ||
| } | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * OpenCRVS is also distributed under the terms of the Civil Registration | ||
| * & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
| * | ||
| * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
| */ | ||
| import { GATEWAY_URL } from '@countryconfig/constants' | ||
| import { URL } from 'url' | ||
| import fetch from 'node-fetch' | ||
|
|
||
| const GRAPHQL_GATEWAY_URL = new URL('graphql', GATEWAY_URL) | ||
|
|
||
| /** Communicates with opencrvs-core's GraphQL gateway */ | ||
| const post = async <T = any>({ | ||
| query, | ||
| variables, | ||
| headers | ||
| }: { | ||
| query: string | ||
| variables: Record<string, any> | ||
| headers: Record<string, any> | ||
| }) => { | ||
| const response = await fetch(GRAPHQL_GATEWAY_URL, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| ...headers | ||
| }, | ||
| body: JSON.stringify({ | ||
| variables, | ||
| query | ||
| }) | ||
| }) | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`not ok: ${await response.text()}`) | ||
| } | ||
|
|
||
| return response.json() as Promise<{ data: T }> | ||
| } | ||
|
|
||
| export const confirmRegistration = ( | ||
| id: string, | ||
| variables: { | ||
| childIdentifiers?: Array<{ type: string; value: string }> | ||
| registrationNumber: string | ||
| trackingId: string | ||
| }, | ||
| { headers }: { headers: Record<string, any> } | ||
| ) => | ||
| post({ | ||
| query: /* GraphQL */ ` | ||
| mutation confirmRegistration( | ||
| $id: ID! | ||
| $details: ConfirmRegistrationInput! | ||
| ) { | ||
| confirmRegistration(id: $id, details: $details) | ||
| } | ||
| `, | ||
| variables: { | ||
| id, | ||
| details: { | ||
| childIdentifiers: variables.childIdentifiers, | ||
| registrationNumber: variables.registrationNumber, | ||
| trackingId: variables.trackingId | ||
| } | ||
| }, | ||
| headers | ||
| }) | ||
|
|
||
| export const rejectRegistration = ( | ||
| id: string, | ||
| { reason, comment }: { reason: string; comment: string }, | ||
| { headers }: { headers: Record<string, any> } | ||
| ) => | ||
| post({ | ||
| query: /* GraphQL */ ` | ||
| mutation rejectRegistration( | ||
| $id: ID! | ||
| $details: RejectRegistrationInput! | ||
| ) { | ||
| rejectRegistration(id: $id, details: $details) | ||
| } | ||
| `, | ||
| variables: { | ||
| id, | ||
| details: { | ||
| reason, | ||
| comment | ||
| } | ||
| }, | ||
| headers | ||
| }) | ||
|
|
||
| type GetUser = { | ||
| getUser: { | ||
| primaryOffice: { | ||
| hierarchy: Array<{ | ||
| id: string | ||
| }> | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export const fetchUserLocationHierarchy = async ( | ||
| userId: string, | ||
| { headers }: { headers: Record<string, any> } | ||
| ) => { | ||
| const res = await post<GetUser>({ | ||
| query: /* GraphQL */ ` | ||
| query fetchUser($userId: String!) { | ||
| getUser(userId: $userId) { | ||
| primaryOffice { | ||
| hierarchy { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `, | ||
| variables: { userId }, | ||
| headers | ||
| }) | ||
| return res.data.getUser.primaryOffice.hierarchy.map(({ id }) => id) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.