Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 107 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"nodemailer": "^5.1.1",
"pg": "^7.8.0",
"reflect-metadata": "^0.1.13",
"type-graphql": "^0.16.0",
"type-graphql": "^1.0.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Upgrading type-graphql to a new major version (1.0.0) introduces breaking changes that will affect your project.

The function formatArgumentValidationError has been removed from type-graphql since v0.17.0. Your code in src/index.ts at line 23 uses this function to format validation errors for Apollo Server, and it is imported on line 4. This will cause a runtime error as the function is no longer exported.

To fix this, you will need to:

  1. Remove the import of formatArgumentValidationError from src/index.ts.
  2. Provide a custom formatError function to the ApolloServer constructor.

Here is an example of how you can implement the formatError function in src/index.ts:

import { GraphQLError } from "graphql";
import { ArgumentValidationError } from "type-graphql";
// ... other imports

// ... in main function
const apolloServer = new ApolloServer({
    schema,
    formatError: (error: GraphQLError) => {
        const originalError = error.originalError;
        if (originalError instanceof ArgumentValidationError) {
            // You can customize the error response here.
            // For example, to expose validation errors:
            return {
                message: error.message,
                locations: error.locations,
                path: error.path,
                extensions: {
                    code: 'GRAPHQL_VALIDATION_FAILED',
                    validationErrors: originalError.validationErrors,
                }
            };
        }
        return error;
    },
    context: ({ req, res }: any) => ({ req, res })
});

This change is necessary for your application to handle validation errors correctly after the upgrade. Without it, your server's error handling for GraphQL validation will be broken.

"typeorm": "^0.2.12",
"uuid": "^3.3.2"
},
Expand Down