graphql-relay-js icon indicating copy to clipboard operation
graphql-relay-js copied to clipboard

fix: fix output type for mutate and get payload

Open Eckzzo opened this issue 1 year ago • 1 comments

Eckzzo avatar Apr 25 '24 14:04 Eckzzo

@benjie would it be possible for you to take a look?

Eckzzo avatar Jul 10 '24 20:07 Eckzzo

this is breaking for everybody

sibelius avatar Jul 10 '24 20:07 sibelius

I would go with a patch or minor

Won’t break for existing use cases

sibelius avatar Jul 11 '24 15:07 sibelius

I'm unfamiliar with this code, however I note from the description:

  • mutateAndGetPayload will receive an Object with a key for each
  • input field, and it should return an Object with a key for each
  • output field. It may return synchronously, or return a Promise.

Currently the type doesn't allow for a promise, so if this is permitted as the comment implies then the types should allow for it.

I'm unsure what the knock-on consequences of this change will be, and if it needs a semver major release.

In case, I would say that doesn't have any side implication of this type definition. It just allows us to handle the mutateAndGetPayload in two ways:

1:

mutateAndGetPayload: () => {
  // ...
}

2:

mutateAndGetPayload: async () => {
  // ...
}

Which is already allowed before, but by the PR we're inserted the generic types, have been strictly removed.

noghartt avatar Jul 11 '24 15:07 noghartt

Ah https://github.com/graphql/graphql-relay-js/pull/389 broke it! Thanks for the info on that @noghartt I can see this is clearly a fix now :+1:

benjie avatar Jul 11 '24 17:07 benjie

I've published this as [email protected]; please can someone confirm that it works correctly and if so I will update the tag from @next to @latest. Thanks!

benjie avatar Jul 11 '24 17:07 benjie