Relay: [modern] relay-compiler flow types for custom scalars

Created on 9 Jun 2017  路  2Comments  路  Source: facebook/relay

Many schemas (e.g. Github) have their own scalar for DateTime and URI, which are always encoded as strings. The flow generator currently defaults to any for any non-standard GraphQL scalars.

Could not convert GraphQLScalarType(DateTime), using 'any'

It would be great if mappings could be provided to the flow generator to let it know that types like DateTime can be typed as String.

The GraphQL schema can't provide this information so I'm guessing this mapping would have to be provided at the babel plugin level?

Most helpful comment

We just switched to use the new Flow type generator and what you are asking is currently hardcoded here https://github.com/facebook/relay/blob/66c3d1d6acf8800c8965fa9fedfcc1f3e1197ec0/packages/relay-compiler/core/RelayFlowGenerator.js#L326

I think we should definitely make this configurable.

All 2 comments

We just switched to use the new Flow type generator and what you are asking is currently hardcoded here https://github.com/facebook/relay/blob/66c3d1d6acf8800c8965fa9fedfcc1f3e1197ec0/packages/relay-compiler/core/RelayFlowGenerator.js#L326

I think we should definitely make this configurable.

Thanks for the input here. We're currently going through old issues that appear to have gone stale (ie. not updated in about the last 3 months) because the volume of material in the issue tracker is becoming hard to manage. If this is still important to you please comment and we'll re-open this.

Thanks once again!

Was this page helpful?
0 / 5 - 0 ratings