Skip to content

Could not serialize term %Kronky.Payload{messages: [], result: true, successful: true} as type Boolean #15

@annrapid

Description

@annrapid

Hi there,
I have a mutation which returns a boolean ( true or false). This is my mutation:

   field :revoke_token, :boolean do
      resolve(fn _, %{context: context} ->
        context[:current_user]
        |> Accounts.signout()
        {:ok, true}
      end)

and this is how I am calling it in react.

 <RevokeTokenMutation mutation={REVOKE_TOKEN}>
            {(revokeToken, { client }) => (
              <a className="navbar-item" href="#logout" onClick={this.logout(revokeToken, client)}>
                Sign out
              </a>
            )}
          </RevokeTokenMutation>

and logout function is

  private logout(revokeToken: Function, client: ApolloClient<any>) {
    return async (event: React.MouseEvent<HTMLElement>) => {
      event.preventDefault();
      const response: MutationResult<RevokeTokenData> = await revokeToken();

      console.log("Response " + response);
      const errors = response.data!.revokeToken.errors;
      if (!errors) {
        window.localStorage.removeItem('yummy:token');
        await client.resetStore();
        this.props.redirect('/', { notice: 'You are well disconnected' });
      }
    };
  }

I am unable to get past the error. Can I not use boolean type?

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