'GraphQL getting error "Upload" is not defined in schema but the app has not any Upload at all

In my backend app built with NodeJS and GraphQL, I'm getting the below error but I have no clue what does it mean. I don't have any Upload inside my app as I do not upload anything but still, there is an error regarding that Upload

base-user-service-1  | 17:34:41 🚨 "Upload" defined in resolvers, but not in schema
base-user-service-1  | Error: "Upload" defined in resolvers, but not in schema
base-user-service-1  |     at /code/dist/schema/src/addResolversToSchema.js:35:23
base-user-service-1  |     at Array.forEach (<anonymous>)
base-user-service-1  |     at addResolversToSchema (/code/dist/schema/src/addResolversToSchema.js:18:28)
base-user-service-1  |     at schemaTransforms (/code/dist/schema/src/makeExecutableSchema.js:66:41)
base-user-service-1  |     at /code/dist/schema/src/makeExecutableSchema.js:108:65
base-user-service-1  |     at Array.reduce (<anonymous>)
base-user-service-1  |     at makeExecutableSchema (/code/dist/schema/src/makeExecutableSchema.js:108:29)
base-user-service-1  |     at createApollo (/code/node_modules/@trialbee/apollo/lib/createApollo.js:64:30)
base-user-service-1  |     at /code/src/server.js:33:23
base-user-service-1  |     at Object.<anonymous> (/code/src/server.js:23:1)
base-user-service-1  |     at Module._compile (node:internal/modules/cjs/loader:1103:14)
base-user-service-1  |     at babelWatchLoader (/code/node_modules/babel-watch/runner.js:58:13)
base-user-service-1  |     at Object.reqExtensions.<computed> [as .js] (/code/node_modules/babel-watch/runner.js:69:7)
base-user-service-1  |     at Module.load (node:internal/modules/cjs/loader:981:32)
base-user-service-1  |     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
base-user-service-1  |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)

I don't know what I should show more or what code snippet as I have no Upload inside my code and cannot understand anything on this.

The only code I have is about the makeExecutableSchema as follow:

const { ApolloServer } = require('apollo-server-express');
const http = require('http');
const express = require('express');
const { execute, subscribe } = require('graphql');
const { assign, get, isEmpty } = require('lodash');
const { ApolloServerPluginDrainHttpServer } = require('apollo-server-core');
const { SubscriptionServer } = require('subscriptions-transport-ws');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const {
  ApolloServerPluginLandingPageGraphQLPlayground,
  ApolloServerPluginLandingPageDisabled,
} = require('apollo-server-core');
const prepareOptions = require('./prepareOptions');

/**
 * @param {Object} options={}
 * @param {express.Router} expressRouter=null
 * @param {Array<string>} options.typeDefs
 * @param {string} options.name
 */

async function createApollo({ options = {}, expressRouter = null }) {
  const subscriptionContext = get(options, 'context', {});

  const expressApp = express();
  const httpServer = http.createServer(expressApp);

  const { serverOptions = {}, log = {} } = prepareOptions(options);

  const customPlugins = [
    ApolloServerPluginDrainHttpServer({
      httpServer,
    }),
    {
      async serverWillStart() {
        return {
          async drainServer() {
            subscriptionServer.close();
          },
        };
      },
    },
    get(serverOptions, 'disablePlayground', false)
      ? ApolloServerPluginLandingPageDisabled()
      : ApolloServerPluginLandingPageGraphQLPlayground(),
  ];

  if (isEmpty(serverOptions.plugins)) {
    serverOptions.plugins = customPlugins;
  } else {
    assign(serverOptions.plugins, [...serverOptions.plugins, ...customPlugins]);
  }

  const apolloServer = new ApolloServer(serverOptions);

  /**
   * @path By default, apollo-server hosts its GraphQL endpoint at the server root.
   * However, *other* Apollo Server packages like apollo-express host it at /graphql.
   * Default to /graphql if not provided within 'options'.
   */
  const path = get(serverOptions, 'path', apolloServer.graphqlPath);

  const subscriptionSchema = makeExecutableSchema({
    typeDefs: get(serverOptions, 'typeDefs', []),
    resolvers: get(serverOptions, 'resolvers', []),
    logger: log,
  });

  const subscriptionServer = SubscriptionServer.create(
    {
      schema: subscriptionSchema,
      execute,
      subscribe,
      onConnect: () => subscriptionContext,
    },
    {
      server: httpServer,
      path,
    }
  );

  /** Must start apollo server before `applyMiddleware` */
  await apolloServer.start();

  /** Custom endpoints provided by user, see examples/server.js for how to use */
  if (
    !isEmpty(expressRouter) &&
    Object.getPrototypeOf(expressRouter) === express.Router
  ) {
    expressApp.use(express.json({ limit: '10mb' }));
    expressApp.use('/api', expressRouter);
  }

  apolloServer.applyMiddleware({
    app: expressApp,
    path,
  });

  /**
   * @httpServer must be used in the consumer service to server listen `httpServer.listen(PORT)`
   * instead of apollo server. As it supports Subscription by listening on both HTTP and WenSocket transports simultaneously
   */
  return {
    httpServer,
    apolloServer,
  };
}

module.exports = createApollo;

This is used in the server.js as follow

(async () => {
  const context = {
    withDAO: transactionalWithDAO(db),
    withLoginAttempts: loginAttemptsDAO(db),
    publish,
    pubsub,
    reminders,
  };

  try {
    const res = await apollo({
      options: {
        name: 'UserService',
        typeDefs,
        resolvers,
        /** default path for graphql and subscription
         * verify that you are using correct url in playground before testing the subscription (with or without /graphql)
         */
        path: '/',
        context,
        cors: true,

        /** Apollo Server will start recording traces of every request it receives and sending summaries of that performance data to Apollo Studio. Studio aggregates and summarizes those traces to provide segmented, filterable insights about your graph's usage. */
        tracing: true,
        disablePlayground: process.env.NODE_ENV === 'production',
      },
    });

    res.httpServer.listen(PORT, () => {
      log.info(
        'Graphql playground is running at http://localhost:%i%s',
        PORT,
        res.apolloServer.graphqlPath
      );
    });
  } catch (error) {
    log.error(error);
  }
})();

Please level a comment if you need to see something specific I didn't include in my question



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source