From 847b4cd62fe2f462af04e7e6e3e023d878522011 Mon Sep 17 00:00:00 2001 From: "EP\\qang2" Date: Mon, 26 Aug 2024 11:38:05 +0700 Subject: [PATCH] Change GraphQL query to get the new data format Fixes: AFORM-4357 --- .../forms-sdk/src/form-loader/formLoader.ts | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/@episerver/forms-sdk/src/form-loader/formLoader.ts b/src/@episerver/forms-sdk/src/form-loader/formLoader.ts index 2de9d1b..f65b371 100644 --- a/src/@episerver/forms-sdk/src/form-loader/formLoader.ts +++ b/src/@episerver/forms-sdk/src/form-loader/formLoader.ts @@ -18,7 +18,7 @@ export class FormLoader { * @param config Optional config to use. This config will combined with the defaultConfig. */ constructor(config?: Partial) { - this.client = new ApiClient({ ...defaultConfig, ...config}); + this.client = new ApiClient({ ...defaultConfig, ...config }); } /** @@ -52,34 +52,37 @@ export class FormLoader { return new Promise((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();