Skip to content

Commit

Permalink
Merge pull request #433 from lahirulakruwan/main
Browse files Browse the repository at this point in the history
Get person by id function graphql api changes added
  • Loading branch information
YujithIsura authored Oct 16, 2024
2 parents c563616 + 4ff50ac commit 9970cce
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 60 deletions.
6 changes: 3 additions & 3 deletions campus/bffs/enrollment/api/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public isolated client class GraphqlClient {
return <GetPersonsResponse>check performDataBinding(graphqlResponse, GetPersonsResponse);
}
remote isolated function getPersonById(int id) returns GetPersonByIdResponse|graphql:ClientError {
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email permanent_address {city {id name {name_en name_si name_ta}} street_address phone id} mailing_address {city {id name {name_en name_si name_ta}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email mailing_address {city {id name {name_en name_si name_ta} district {id name {name_en}}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
map<anydata> variables = {"id": id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetPersonByIdResponse>check performDataBinding(graphqlResponse, GetPersonByIdResponse);
Expand All @@ -53,10 +53,10 @@ public isolated client class GraphqlClient {
return <GetDistrictsResponse>check performDataBinding(graphqlResponse, GetDistrictsResponse);
}
remote isolated function getCities(int district_id) returns GetCitiesResponse|graphql:ClientError {
string query = string `query getCities($district_id:Int!) {cities(district_id:$district_id) {id name {name_en} district {id name {name_en}}}}`;
string query = string `query getCities($district_id:Int!) {cities(district_id:$district_id) {id name {name_en}}}`;
map<anydata> variables = {"district_id": district_id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetCitiesResponse> check performDataBinding(graphqlResponse, GetCitiesResponse);
return <GetCitiesResponse>check performDataBinding(graphqlResponse, GetCitiesResponse);
}
remote isolated function getAllOrganizations() returns GetAllOrganizationsResponse|graphql:ClientError {
string query = string `query getAllOrganizations {all_organizations {id name {name_en} address {id street_address} avinya_type {id name} description phone notes}}`;
Expand Down
23 changes: 5 additions & 18 deletions campus/bffs/enrollment/api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,12 @@ public type GetPersonByIdResponse record {|
string? name_si;
string? name_ta;
|} name;
|} city;
string? street_address;
int? phone;
int? id;
|}? permanent_address;
record {|
record {|
int? id;
record {|
string? name_en;
string? name_si;
string? name_ta;
|} name;
int? id;
record {|
string? name_en;
|} name;
|} district;
|} city;
string? street_address;
int? phone;
Expand Down Expand Up @@ -381,12 +374,6 @@ public type GetCitiesResponse record {|
record {|
string? name_en;
|} name;
record {|
int? id;
record {|
string? name_en;
|} name;
|} district;
|}[] cities;
|};
public type GetAvinyaTypesResponse record {|
Expand Down
25 changes: 6 additions & 19 deletions campus/bffs/enrollment/graphql_client/enrollment.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ query getPersonById($id: Int!) {
created
updated
jwt_email
permanent_address {
city {
id
name {
name_en
name_si
name_ta
}
}
street_address
phone
id
}
mailing_address {
city {
id
Expand All @@ -111,6 +98,12 @@ query getPersonById($id: Int!) {
name_si
name_ta
}
district {
id
name {
name_en
}
}
}
street_address
phone
Expand Down Expand Up @@ -271,12 +264,6 @@ query getCities($district_id: Int!) {
name {
name_en
}
district {
id
name {
name_en
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public isolated client class GraphqlClient {
return <GetPersonsResponse> check performDataBinding(graphqlResponse, GetPersonsResponse);
}
remote isolated function getPersonById(int id) returns GetPersonByIdResponse|graphql:ClientError {
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email permanent_address {city {id name {name_en name_si name_ta}} street_address phone id} mailing_address {city {id name {name_en name_si name_ta}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email mailing_address {city {id name {name_en name_si name_ta} district {id name {name_en}}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
map<anydata> variables = {"id": id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetPersonByIdResponse> check performDataBinding(graphqlResponse, GetPersonByIdResponse);
Expand All @@ -52,7 +52,7 @@ public isolated client class GraphqlClient {
return <GetDistrictsResponse> check performDataBinding(graphqlResponse, GetDistrictsResponse);
}
remote isolated function getCities(int district_id) returns GetCitiesResponse|graphql:ClientError {
string query = string `query getCities($district_id:Int!) {cities(district_id:$district_id) {id name {name_en} district {id name {name_en}}}}`;
string query = string `query getCities($district_id:Int!) {cities(district_id:$district_id) {id name {name_en}}}`;
map<anydata> variables = {"district_id": district_id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetCitiesResponse> check performDataBinding(graphqlResponse, GetCitiesResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,12 @@ public type GetPersonByIdResponse record {|
string? name_si;
string? name_ta;
|} name;
|} city;
string? street_address;
int? phone;
int? id;
|}? permanent_address;
record {|
record {|
int? id;
record {|
string? name_en;
string? name_si;
string? name_ta;
|} name;
int? id;
record {|
string? name_en;
|} name;
|} district;
|} city;
string? street_address;
int? phone;
Expand Down Expand Up @@ -693,12 +686,6 @@ public type GetCitiesResponse record {|
record {|
string? name_en;
|} name;
record {|
int? id;
record {|
string? name_en;
|} name;
|} district;
|}[]? cities;
|};

Expand Down

0 comments on commit 9970cce

Please sign in to comment.