Skip to content

Commit

Permalink
Merge pull request #136 from episerver/feature/AFORM-4357-change-grap…
Browse files Browse the repository at this point in the history
…hQL-query

Change GraphQL query to get the new data format
  • Loading branch information
epi-qang2 authored Aug 26, 2024
2 parents d127074 + 847b4cd commit 65b5964
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/@episerver/forms-sdk/src/form-loader/formLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class FormLoader<T extends FormContainer> {
* @param config Optional config to use. This config will combined with the defaultConfig.
*/
constructor(config?: Partial<ApiClientConfig>) {
this.client = new ApiClient<T>({ ...defaultConfig, ...config});
this.client = new ApiClient<T>({ ...defaultConfig, ...config });
}

/**
Expand Down Expand Up @@ -52,34 +52,37 @@ export class FormLoader<T extends FormContainer> {
return new Promise<T>((resolve, reject) => {
let query: string = `
query FormQuery($key: String, $language: String) {
FormContainerBlock (
where: {
ContentLink: {
GuidValue:{eq: $key}
}
Language: {
Name: {eq: $language}
}
}
){
FormContainer(where: { Key: { eq: $key }, Locale: { eq: $language } }) {
items {
FormRenderTemplate
Key
Locale
Properties
Localizations
FormElements {
Key
ContentType
DisplayName
Locale
Localizations
Properties
Locale
}
}
}
}
`;
let variables: any = { key: parseKeyToGuid(key), language };
let variables: any = { key: key, language };
fetch(optiGraphUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query,
variables,
}),
})
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query,
variables,
}),
})
.then(async (response: Response) => {
if(response.ok){
let json = await response.json();
Expand Down

0 comments on commit 65b5964

Please sign in to comment.