Skip to content

BUG: .$push does not add variables to variable definitions on mutation #175

Open

Description

@kempsteven

image

As you can see in the image above:
The variable is_create_update_xero is not in the variable definitions of updateUser.

Here is the code that I use:

async updateUser () {
      await User.fetch({ id: this.authUser.id })

      await User.insertOrUpdate({
        where: this.authUser.id,
        data: {
          ...this.authUser,
          is_email_verified: true
        }
      })

      const user = User
        .query()
        .where('id', this.authUser.id)
        .first()

      await user.$push({ is_create_update_xero: false })
 }

Mutation Type Def

updateUser(
     id: ID!,
     user: UserInput,
     is_create_update_xero: Boolean
 ): User

aaaaaaaand another weird thing about it is when i do this in another place on the app(authenticated page), it adds the variable definition for is_create_update_xero.
not sure if having an authenticated page changes anything.
Please help :(

Activity

  1. kempsteven commented on Mar 4, 2021

    @kempsteven
    Author

    UPDATE:

    There is a bug where if you passed a false/falsy variable on a mutation it will not register the variable definition :coffin_dance:
    Example:

    user.$push({ is_create_update_xero: false }) or user.$push({ is_create_update_xero: 0 })

    that will create a query of

    query: "mutation UpdateUser($id: ID!, $user: UserInput!)..."
    variables: { is_create_update_xero: false, id: '...', user: {...} }

    as you can see the $is_create_update_xero: Boolean! is missing in the variable definition in the query.
    Without the variable definition, the back end won't be able to receive the is_create_update_xero

    Work around:
    I just passed a "false" string: user.$push({ is_create_update_xero: 'false' }) , it looks reallyyy bad
    but that's the only workaround I could think of

  2. changed the title [-].$push does not add variables to variable definitions on mutation[/-] [+]BUG: .$push does not add variables to variable definitions on mutation[/+] on Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions