Skip to content

fix(vue-apollo): default to empty options in all mutations #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 18, 2023
Merged

fix(vue-apollo): default to empty options in all mutations #45

merged 5 commits into from
Jan 18, 2023

Conversation

FloEdelmann
Copy link
Contributor

@FloEdelmann FloEdelmann commented Jan 13, 2023

... even those with required variables, as those don't have to be passed when creating the query, but only when calling mutate.

Description

When you have a GraphQL mutation with non-nullable inputs, the function created by @graphql-codegen/typescript-vue-apollo makes the options parameter required instead of defaulting to an empty object {}.

However, you can still manually pass {}, since the actual variables don't have to be set in the useAbcMutation function, but can also be passed in the mutate function:

const {mutate} = useAbcMutation({}) // should default to {}

mutate({ input: 'foo' })

E.g. for this mutation:

mutation Abc($input: String!) {
  updateAbc(input: $input) {
    id
  }
}

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Not tested, but I think the issue is better highlighted in the PR.

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

even those with required variables, as those don't have to be passed when creating the query, but only when calling `mutate`
@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2023

🦋 Changeset detected

Latest commit: 5936729

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@saihaj saihaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test for this?

@saihaj
Copy link
Collaborator

saihaj commented Jan 17, 2023

can you add a patch changeset for this #45 (comment)

@saihaj saihaj merged commit 296ce64 into dotansimha:main Jan 18, 2023
@omjadas omjadas mentioned this pull request Jan 22, 2023
9 tasks
@github-actions github-actions bot mentioned this pull request Jan 22, 2023
@saihaj
Copy link
Collaborator

saihaj commented Jan 22, 2023

released https://github.com/dotansimha/graphql-code-generator-community/releases/tag/release-1674417409150

@FloEdelmann FloEdelmann deleted the patch-1 branch January 22, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants