Skip to content
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

Types for input objects should not have a prototype #5964

Open
Tracked by #8296 ...
bezreyhan opened this issue May 7, 2021 · 2 comments
Open
Tracked by #8296 ...

Types for input objects should not have a prototype #5964

bezreyhan opened this issue May 7, 2021 · 2 comments
Labels
core Related to codegen core/cli stage/0-issue-prerequisites Needs more information before we can start working on it

Comments

@bezreyhan
Copy link

Describe the bug

The Javascript object that is returned for mutation inputs does not have a prototype but this is not reflected in the generated types.

See issue here: ardatan/graphql-tools#1374

To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL operations:
{
  Mutation: {
    someMutation(_, { input }) {
        input.hasOwnProperty() // this will throw an error since input does not have a prototype
    } 
  }
}
  1. My codegen.yml config file:
overwrite: true
schema: '...'
documents: null
generates:
  src/...
    config:
      noSchemaStitching: true
      useIndexSignature: true
      namingConvention:
        enumValues: 'change-case#upperCase'
    plugins:
      - add:
          content: '/* tslint:disable */'
      - 'typescript'
      - 'typescript-resolvers'

Expected behavior

Can we create a special type for object-inputs to null out all of their prototype fields?

@Urigo
Copy link
Collaborator

Urigo commented May 12, 2021

Hi @bezreyhan and thank you for the report!

Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow.

It seems like we are on stage 0.
Now in order to advance to stage 1 we'll need an easily running reproduction, do you think you can create that on code sandbox?
After that, maybe someone can help with advancing it into stage 2 by creating a failing test?

Thank you and sorry that this comment is not a complete solution (yet).

@Urigo Urigo added the stage/0-issue-prerequisites Needs more information before we can start working on it label May 12, 2021
@dotansimha
Copy link
Owner

@bezreyhan I think I need more context here. Why does the codegen types effect this? we just use { ... } to define the TS types. Is there an alternative way for this?

@charlypoly charlypoly added the core Related to codegen core/cli label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli stage/0-issue-prerequisites Needs more information before we can start working on it
Projects
None yet
Development

No branches or pull requests

4 participants