How to update default value on GraphQL schema value via button? Flutter

Viewed 11

Hello I hope I can explain what I am trying. In GraphQL I have a default status

type Objective @model @auth(rules: [{ allow: owner }]) {
id: ID!
type: ObjectiveTypes!
status: ObjectiveStatuses @default(value: "DRAFTED")

} I want to change this status to Active after the user presses a button.

enum ObjectiveStatuses {
    ACTIVE 
    DRAFTED
}

All necessary backend operations have been completed. I created a boolean called isDrafted on the frontend. How can I write a function based on this boolean and convert it to active?

final bool isActive = goal.status == ObjectiveStatuses.ACTIVE;
final bool isDrafted = goal.status == ObjectiveStatuses.DRAFTED;

Here is checking if status is drafted or active.

            Row(
              children: [
                Expanded(
                  child: AppButtons.button(
                    onPressed: () => activeState(),
                    appButtonSize: AppButtonsSize.smallNoPadding,
                    child: Text(context.l10n.buttonStartSavings),
                  ),
                ),
              ],
            )

this activeStatus function should be active the Objective status. But somehow I could not implement it and maybe i missed something. Thank you in advance!

If the question is not clear tell me I will update it.

0 Answers
Related