You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when generating graphql types for flow, if we apply the --useFlowExactObjects flag we get:
typeUser={|__typename: "User",name: string,|}
and if we don't specify the flag (ie, we want inexact objects), we get
typeUser={__typename: "User",name: string,}
The problem is with the second one – flow is moving towards exact objects being the default, and have added an optional lint warning that triggers when an inexact object is declared implicitly (ie, without the new ... syntax.
So I'm suggesting that the default behaviour should be changed such that if this library creates an inexact object, it will do it with the required .... Ie:
typeUser={__typename: "User",name: string,
...
}
This would be a breaking change for some users, as flow<0.84 is unable to parse the ... syntax. However, 0.84 is quite an old version at this point and we could perhaps add a --useOldFlowInexactSyntax flag to keep it working for them.
If the breaking change doesn't appeal, we could do the opposite – the default behaviour is unchanged, and you can enable the new behaviour with a --useNewFlowInexactSyntax.
Hope this makes sense. Thanks!
The text was updated successfully, but these errors were encountered:
If anyone's interested, I managed to work around this using jscodeshift. Every time I generate the graphql types, I run jscodeshift -t codeshift_makeInexactExplicit.js on each of the files generated by apollo (I had to do a bit of jiggery pokery with find to make sure I only ran it on the apollo codegen output rather than my own product code).
Currently when generating graphql types for flow, if we apply the
--useFlowExactObjects
flag we get:and if we don't specify the flag (ie, we want inexact objects), we get
The problem is with the second one – flow is moving towards exact objects being the default, and have added an optional lint warning that triggers when an inexact object is declared implicitly (ie, without the new
...
syntax.So I'm suggesting that the default behaviour should be changed such that if this library creates an inexact object, it will do it with the required
...
. Ie:This would be a breaking change for some users, as flow<0.84 is unable to parse the
...
syntax. However, 0.84 is quite an old version at this point and we could perhaps add a--useOldFlowInexactSyntax
flag to keep it working for them.If the breaking change doesn't appeal, we could do the opposite – the default behaviour is unchanged, and you can enable the new behaviour with a
--useNewFlowInexactSyntax
.Hope this makes sense. Thanks!
The text was updated successfully, but these errors were encountered: