graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

flow-operations tries to spread inexact objects

Open Athelian opened this issue 2 years ago • 4 comments

Edit: I found the line causing this issue. I would suggest making it check the config for whether or not flowExactObject is specified and then making it an exact typename object. I can make a PR if devs agree with this change.

Describe the bug

flow-operations makes its own $Pick util function and then tries to spread the results of it into a merged object which also includes inexact types.

Please try removing the question mark on line 9 from the FlowTry, or try making {__typename: "Reference"} exact like {|__typename: "Reference"|}:

My codebase produces this problem in large quantities.

Your Example Website or App

https://flow.org/try/#0FAFwngDgpgBAJABQJYGMDWAeA8gJyQcyQDsAuGLAIwCsoUQAaGAaSjAGczKa6A+GAXnhcAsgEMISDC3aMprHgAo0ZaQEoBfOAFEANlAC2UIiAAqkKNjyEijaTx4BuYKHMwcUAGZR3RFLEEA3gA+ogD8ZBQA9pF6okRBAL7O4NAwHjqRAO5Y0DiiIEiRRGxmqYHAMDAAdDUBMAD69SlGooZkAOQASp7eRn7tMAn0FdU1iKiY7l4+fowjwTBhZABUMIk8wEnAKEVsIDAgUHtk6Vk53vmFxaX+MAGNzUStUGQARN3TfVCvjKJkIDgAK5QBJAA

Steps to Reproduce the Bug or Issue

Generate types from an exact object with an optional property type.

Expected behavior

The typename object should be exact.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Flow: 0.181.2
  • @graphql-codegen/flow-operations version: ^2.2.13

Codegen Config File

documents: 'src/graphql/**/*.js'
generates:
  src/generated/graphql.js:
    plugins:
      - codegen-custom-plugin.js

Additional context

No response

Athelian avatar Jun 30 '22 12:06 Athelian

I am having the same issue. Did you manage to get a solution to this?

simkessy avatar Aug 23 '22 00:08 simkessy

I am having the same issue. Did you manage to get a solution to this?

Sorry I didn't see your reply. I ended up making a custom codegen plugin, copy pasting source code from the flow-operations node module and adjusting the line I mentioned in this issue.

Athelian avatar Aug 29 '22 04:08 Athelian

Could you make a PR so they could integrate the solution?

simkessy avatar Aug 29 '22 19:08 simkessy

Could you make a PR so they could integrate the solution?

https://github.com/dotansimha/graphql-code-generator/pull/8299

Athelian avatar Aug 30 '22 02:08 Athelian