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

Invalid generated ScalarConfig type for flow types #1404

Closed
emmenko opened this issue Mar 5, 2019 · 3 comments
Closed

Invalid generated ScalarConfig type for flow types #1404

emmenko opened this issue Mar 5, 2019 · 3 comments
Labels
plugins waiting-for-release Fixed/resolved, and waiting for the next stable release

Comments

@emmenko
Copy link

emmenko commented Mar 5, 2019

Describe the bug
The generated ScalarConfig are invalid for flow types.

To Reproduce
Given a scalar type (e.g. DateTime), a DateTimeScalarType is generated of kind interface. However, the GraphQLScalarTypeConfig flow type from graphql is a type, which makes it impossible to extend as an interface.

image

For TypeScript, the GraphQLScalarTypeConfig is an interface, which makes it extendible, but not for FlowType.

Expected behavior
I wonder what the purpose of this ScalarConfig is in the first place. Is it really necessary to have? I tried to find some explanations in the commit history but the only things I found are:

I am also unsure on how the GraphQLScalarTypeConfig can be "extended". Being a type, it's not really possible to do, even with intersections, especially given that the name property is literal.

Example: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgDiATgIY4AWAigDIDKAxqTKcQCq54DCcAdlAEsA5mAC8YAN4AfML1IBbPAC4wAZwzEBvEVIC+AbkycwAEVIY8bAYsbNWPfsLFEylWrZbtODwSIBkkrIKymAA5GYWVoqhYAboAG6sYIkwAK4hEZbWeB72fL7OEqhgQYoqoQD8FaEANKgGQA

Environment:

  • OS: macOS
  • Codegen: latest version 0.18.0
  • Node: 11

Maybe I'm doing something wrong or I'm missing something. It would be good to understand the reasons for having that and what are we supposed to do about it.

Many thanks! 🙏

@dotansimha
Copy link
Owner

Hi @emmenko ! Thank you for reporting it.

The right way to do it in flow is to use spread, like that:

type DateTimeScalarConfig = { ...GraphQLScalarTypeConfig, name: 'DateTime' };

I fixed it in this PR: #1520

@dotansimha dotansimha added the waiting-for-release Fixed/resolved, and waiting for the next stable release label Mar 20, 2019
@dotansimha
Copy link
Owner

Fix available in 1.0.2.

@emmenko
Copy link
Author

emmenko commented Mar 20, 2019

The right way to do it in flow is to use spread

Ah good to know! Thanks a lot for the fix 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugins waiting-for-release Fixed/resolved, and waiting for the next stable release
Projects
None yet
Development

No branches or pull requests

3 participants