Closed thanatchakromsang closed 6 years ago
I'm not sure exactly what that library and the type is about, but the Upload
scalar represents a Promise, that resolves an object like you noted (for the current version, it's about to change a little). It can't be serialized.
@jaydenseric Thanks for short notice on the upcoming version!, as for the library it's an auto-generated type for schema but put that aside I still don't know what cause it to be like that
Well, here is the source for the GraphQLUpload
scalar: https://github.com/jaydenseric/apollo-upload-server/blob/v6.0.0-alpha.1/src/types.mjs#L3
Is there a way it can somehow be improved so auto-generated types are more useful? Does a type make sense in this context? Perhaps this is really an issue to be solved in the auto-type-generation library.
Hey @thanatchakromsang what generator are you using for that type system? Using apollo-cli you can use --passthroughCustomScalars
and --customScalarsPrefix
for both Flow and TypeScript generators, which allows you to define types for custom scalars.
For example, I use:
apollo codegen:generate --clientSchema=./src/schema/client.graphql --schema=../../schema/server.graphql --queries=\"src/**/*.js\" --target=flow --addTypename --passthroughCustomScalars --customScalarsPrefix=GraphQL --useFlowReadOnlyTypes
// @flow
declare type GraphQLUpload = File | Blob;
(Didn't mean to close; hit the wrong button.)
OK, I see in your title that you're using graphql-binding
. It looks like this is a limitation of their generator, so I am going to close this here. They will likely need to implement better support for custom scalars on their end to get correct typing.
@mike-marcacci Thanks for clearing that up for me :)
I Fix this issue by modifying TypescriptGenerator in Graphql-binding libs to include custom scalar Mapping Thanks to your input!
is it suppose to be like this below?