-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use empty arrays instead of undefined properties #1259
Conversation
I'd prefer to see no defined property instead of empty arrays when extension is never attempted - this should avoid allocations for larger schema and keep debugging views simpler |
@leebyron Valid points. That's why I would never suggest doing something like this for AST nodes. However, in case of GraphQL schema I think they are less critical:
It doesn't affect graphql-js/src/type/definition.js Lines 603 to 608 in 499a759
It's definitely not a problem for
return type.astNode
? type.extensionASTNodes
? [type.astNode].concat(type.extensionASTNodes)
: [type.astNode]
: type.extensionASTNodes || []; |
57fddc0
to
fc80e6b
Compare
I'd probably also (slightly) prefer to keep extensions undefined for empty: there might be hundreds or thousands of different On the other hand, for |
fc80e6b
to
f437b32
Compare
@mjmahone Agree. I removed
Majority of the issues would be solved by #1331 |
I really like what's happening in #1331 so I'd personally advocate merging that and closing this one. |
@mjmahone I agree with your arguments about |
Yup I agree: |
This PR makes
extensionASTNodes
and__allowedLegacyNames
fields to always be arrays similar to other places in this lib:graphql-js/src/type/definition.js
Line 619 in 499a759
graphql-js/src/type/definition.js
Line 947 in 499a759