Skip to content

Commit

Permalink
feature: Use postgraphile's dynamicJson option.
Browse files Browse the repository at this point in the history
BREAKING CHANGE:  JSON fields should not be parsed or stringified anymore
  • Loading branch information
matthieu-foucault committed Nov 7, 2019
1 parent 0cbba0a commit bf2e831
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/containers/Applications/ApplicationWizardStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ const ApplicationWizardStep = ({
const [initialData, setInitialData] = useState(undefined);

// Function: store the form result
const storeResult = async res => {
const storeResult = async formResult => {
const {environment} = relay;
const variables = {
input: {
id: formResult.id,
formResultPatch: {
formResult: JSON.stringify(res)
formResult
}
}
};
Expand Down Expand Up @@ -200,16 +200,15 @@ const ApplicationWizardStep = ({
};

const onValueChanged = async change => {
const formData = change.data;
// Console.log('form data', formData);
const {formData} = change;
await storeResult(formData);
};

useEffect(() => {
if (!formResult) return;
const {formJsonByFormId} = formResult;
if (formResult.formResult !== '{}') {
return setInitialData(JSON.parse(formResult.formResult));
return setInitialData(formResult.formResult);
}

if (!formJsonByFormId.prepopulateFromSwrs) return setInitialData(undefined);
Expand Down
1 change: 1 addition & 0 deletions app/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ app.prepare().then(() => {
graphiql: true,
classicIds: true,
enableQueryBatching: true,
dynamicJson: true,
pgSettings(req) {
const claims = {};
if (
Expand Down

0 comments on commit bf2e831

Please sign in to comment.