Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

"‘Upload’ scalar serialization unsupported." #12

Closed
bkstorm opened this issue Jul 9, 2019 · 7 comments
Closed

"‘Upload’ scalar serialization unsupported." #12

bkstorm opened this issue Jul 9, 2019 · 7 comments

Comments

@bkstorm
Copy link

bkstorm commented Jul 9, 2019

Hi guy.
I encounter an error when using Upload scalar to upload files with mergeSchemas, this type is supported by Apollo server.

"‘Upload’ scalar serialization unsupported."

I think I found the problem.
v5.2.0...v6.0.0
In the function serializeArgumentValue of the file AddArgumentsAsVariables.ts, you call

    if (nullableType instanceof graphql_1.GraphQLEnumType || nullableType instanceof graphql_1.GraphQLScalarType) {
        return nullableType.serialize(value);
    }

But here is the implementation of Upload scalar

export const GraphQLUpload = new GraphQLScalarType({
  name: 'Upload',
  description: 'The `Upload` scalar type represents a file upload.',
  parseValue: value => value,
  parseLiteral() {
    throw new Error('‘Upload’ scalar literal unsupported.')
  },
  serialize() {
    throw new Error('‘Upload’ scalar serialization unsupported.')
  }
})

So that's why the error is threw.
It would be good if we can check GraphQLUpload type.

@bkstorm
Copy link
Author

bkstorm commented Jul 9, 2019

The reason I have to use version 6.0.0 because version 6.1.4 has a problem with hasura, I can't execute every hasura's queries.
It seems like it's fixed in the latest version: 6.1.5, so I will close this issue.
schema stitching is deprecated by apollo, thank you for supporting it.
Update
My mistake, the latest version doesn't work with hasura when using mergeSchemas
I will try to create a repository to reproduce the error.

@bkstorm bkstorm closed this as completed Jul 9, 2019
@bkstorm bkstorm reopened this Jul 9, 2019
@bkstorm
Copy link
Author

bkstorm commented Jul 9, 2019

I close this issue due to Upload scalar error is fixed in the latest version.
Update
Upload scalar doesn't work with the latest version. A workaround is customizing Upload scalar type

export const UploadScalar = new GraphQLScalarType({
  name: 'Upload',
  description: 'The `Upload` scalar type represents a file upload.',
  parseValue(value: any) {
    return value
  },
  serialize(value: any) {
    return value
  },
  parseLiteral(ast) {
    throw new Error('‘Upload’ scalar literal unsupported.')
  },
})

@bkstorm bkstorm closed this as completed Jul 9, 2019
@bkstorm bkstorm reopened this Jul 9, 2019
@yaacovCR
Copy link
Owner

yaacovCR commented Jul 9, 2019

Thanks for pointing this out. I think your workaround is the best way to go, as it seems like we shouldn't have to maintain a list of scalars that don't support serialization. I suppose we could wrap the serialize call in a try block and catch the error?

Can you also open another issue with whatever problem you are having with hasura? Or is that the same issue?

@yaacovCR
Copy link
Owner

yaacovCR commented Jul 9, 2019

Or perhaps an issue should be opened at graphql-upload to support serialization.

@bkstorm
Copy link
Author

bkstorm commented Jul 10, 2019

Thanks for pointing this out. I think your workaround is the best way to go, as it seems like we shouldn't have to maintain a list of scalars that don't support serialization. I suppose we could wrap the serialize call in a try block and catch the error?

Can you also open another issue with whatever problem you are having with hasura? Or is that the same issue?

Ok, I'm going to open a new issue about hasura.

@bkstorm bkstorm closed this as completed Jul 10, 2019
@yaacovCR
Copy link
Owner

yaacovCR commented Oct 4, 2019

@bkstorm, I think there are other problems with graphql upload and remote schemas. See ardatan#671 and jaydenseric/graphql-upload#56.

@yaacovCR
Copy link
Owner

Latest version of this fork provides the patched Upload scalar and a createServerHttpLink method that creates a terminating link for a subschema that can proxy uploads.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants