Closed joakimunge closed 3 years ago
In the GraphQLUpload
scalar docs, you can see an example titled “A schema built using makeExecutableSchema
from @graphql-tools/schema
.”:
https://github.com/jaydenseric/graphql-upload#class-graphqlupload
In your case, you are using apollo-server
so it's not exactly like the example because your provide typeDefs
and resolvers
to the ApolloServer
constructor, but it's pretty much the same thing:
new ApolloServer({ typeDefs, resolvers });
Make sure that your typeDefs
configured for Apollo Server include scalar Upload
, and that the resolvers
configured contain Upload: GraphQLUpload
, where GraphQLUpload
is imported from graphql-upload
.
Once the Upload
scalar configured for your schema, you should then just be able to use Upload
as a type throughout your schema, just like String
, etc.
For the record, I don't recommend having GraphQL SDL string typeDefs
and separate JS resolvers
that a tool brings together; it's better to use GraphQL.js to just compose your schema using regular JavaScript modules and then provide it to the ApolloServer
constructer with the schema
option, like this:
Hope that helps :)
Hey, I'm pretty new to using custom Scalars and had a question regarding this.
I'm trying to use the Scalar provided by this package, but in our projects we're using the
gql
template literal utility provided by apollo server to define our type defs, like so:How would I go about importing the GraphQlUpload scalar and using it in the template literal?
Thanks