-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Couldn't find type Upload in any of the schemas #286
Comments
same here. Currently, I have to mix
|
I am also running into this. Any ideas how to solve it? |
As said in the OP:
|
Just noticed. (I deleted the comment). To my understanding, this happens because of the way Because of that, it throws an exception that Did anyone perhaps test the behaviour with GraphQL Yoga? I hope that helps with understanding, sorry for the previous answer. |
Fix the error by putting the scheme const typeDefs = gql |
I have the same problem, look at my server implementation const { ApolloServer, gql } = require('apollo-server-express')
const { importSchema } = require('graphql-import')
const express = require('express')
const app = express()
const routes = require('./routes')
initServer();
function initServer() {
try {
const mutationDefs = gql`
scalar Upload
type Mutation {
uploadFotoColaborador(file: Upload!): File!
}
`
const resolvers = require('./resolvers')
const context = require('./config/context')
const schemaPath = './src/schema/index.graphql';
const basicDefs = importSchema(schemaPath)
const serverGraphQL = new ApolloServer({
typeDefs:[basicDefs, mutationDefs],
resolvers,
context
});
serverGraphQL.applyMiddleware({ app, path: '/api' })
app.use(express.json())
app.use(routes)
app.listen({ port: 4000 }, () => {
console.log('Executando em localhost:4000')
})
}
catch (error) {
console.log(`Servidor não pode ser inicializado: ${error}`)
}
} |
I'm still trying to get the whole setup working, but perhaps the following workaround might be of use to someone:
Makes the toolset happy, because EDIT: I can confirm, this workaround is working fine. |
@amiiit will perform the tests, thank you very much! |
@amiiit that doesn't work for me, I still get the error. I'm on version |
the error is because importSchema throw an error if it find type Upload used but not defined in Schema. the temporary solution is to remove "scalar Upload" after importSchema read it. |
This issue makes |
Available in 1.0.0! |
I was having the same problem and by reading @hyochan comment i found out it's because of the name of scalar we put. |
I was trying to get the file upload working in my graphql server by following
https://blog.apollographql.com/file-uploads-with-apollo-server-2-0-5db2f3f60675
In the article the author mentions that Apollo automatically adds the
Upload
type to the schema. However, when importing my typeDefs using graphql-import I am getting the error:Error: Field file: Couldn't find type Upload in any of the schemas. at collectNode (/home/--/--/node_modules/graphql-import/src/definition.ts:154:15)
When adding
scalar Upload
to theschema.graphql
file I get the error:Error: There can be only one type named "Upload". at assertValidSDL (/home/--/--/node_modules/graphql/validation/validate.js:89:11)
Thanks
The text was updated successfully, but these errors were encountered: