graphql-compose / graphql-compose/graphql-compose-mongoose
Type with name "Upload" does not exists
- Dominant language
- TypeScript
- Stars
- 706
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I'm continually getting this error when I'm trying to use `Upload` scalar within my schema. I've followed and read a ton of posts and SO links but can't seem to get past this.
```sh
3|server:watch | throw new Error(`Type with name ${(0, _misc.inspect)(typeName)} does not exists`);
3|server:watch | ^
3|server:watch | Error: Type with name "Upload" does not exists
3|server:watch | at SchemaComposer.get (/Users/andrewmartin/code/server/node_modules/graphql-compose/lib/TypeStorage.js:44:13)
```
This happens when I try to add the field directly like so:
```ts
UserTC.addFields({
image: 'Upload',
})
```
I'm trying to add an `Upload` type. This type, by the way, *works successfully* against my schema and in non-compose / TC resolvers:
```buildSchema.ts
const schemaPath = join(__dirname, '../../../src/gql/schema/**/*.graphql')
const schemaFiles = loadSchemaSync(schemaPath, {
loaders: [new GraphQLFileLoader()],
})
logger.info(`loaded schema! from path: ${schemaPath}`)
const uploadSchema = makeExecutableSchema({
typeDefs: `scalar Upload`,
resolvers: { Upload: GraphQLUpload },
})
const schemaComposer = new SchemaComposer(uploadSchema)
export const schemaWithResolvers = addResolversToSchema({
resolvers,
schema: schemaFiles,
})
schemaComposer.merge(schemaWithResolvers)
schemaComposer.Query.addFields({
...UserQuery,
...PageQuery,
...MenuQuery,
})
schemaComposer.Mutation.addFields({
...adminAccess(UserMutation),
...adminAccess(PageMutation),
...MenuMutation,
})
schemaComposer.merge(schemaWithResolvers)
export const schema = schemaComposer.buildSchema()
```
Main part of interest is here:
```ts
const uploadSchema = makeExecutableSchema({
typeDefs: `scalar Upload`,
resolvers: { Upload: GraphQLUpload },
})
```
I've seen some weird workarounds people are doing to add it successfully when `Mutation.addFields` is hit, but that won't work well for my case because I want to simply add a new argument onto the types available. Any workarounds?
Thanks in advance for your help.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.