-
-
Notifications
You must be signed in to change notification settings - Fork 676
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
formatArgumentValidationError causing typescript error #258
Comments
Hi @jansselt, the typings of |
Alright, will downgrade for now until this is updated to coincide. Thanks @vfaramond . Was going crazy. |
@19majkel94, sorry for creating duplicate. Do we plan fix this issue? |
There is a lot of weird type changes in I will wait for it to settle down and then re-investigate whether it really changed the signature or the API. |
In the meantime, this is the custom implementation of
|
Basically, looks like in new ApolloServer the {
"errors": [
{
"message": "Argument Validation Error",
"locations": [
{
"line": 22,
"column": 3
}
],
"path": [
"addRecipe"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"validationErrors": [
{
"target": {
"title": "Correct title",
"description": "Too short description"
},
"value": "Too short description",
"property": "description",
"children": [],
"constraints": {
"length": "description must be longer than or equal to 30 characters"
}
}
],
"stacktrace": [
"Error: Argument Validation Error",
" at Object.<anonymous> (F:\\#Projekty\\type-graphql\\src\\resolvers\\validate-arg.ts:29:11)",
" at Generator.throw (<anonymous>)",
" at rejected (F:\\#Projekty\\type-graphql\\node_modules\\tslib\\tslib.js:105:69)",
" at processTicksAndRejections (internal/process/next_tick.js:81:5)"
]
}
}
}
],
"data": null
} |
I've tested that so I will remove the {
"errors": [
{
"message": "Argument Validation Error",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": ["addRecipe"]
}
],
"data": null
} |
Fixed via 526886c 🔒 Released in |
It probably doesn't works for validation in nested objects. 😞 |
@Myiyk See #133 - nested inputs are not an instance, so they can't be validated using |
@git-no |
You can't simply remove functionality. This is a breaking change. |
@venatir Please check twice before starting to complain: It was clearly released as the new major version with a "breaking change" notice 😠 |
@galkin Oh, you think it's the source of confusion. Basically major 0 release has a different semver: At least that's the way npm handles deps 😉 |
My bad. Was aware of the above (0 Major different behaviour), but I read the version from a different package (apollo-server-core) and somehow was convinced this was v2.10.0 :) Please ignore me :) Either way it's great too see you guys are so active and answer this fast. Great maintenance work! |
I can confirm this works however add the following lines to your code: import { GraphQLError, GraphQLFormattedError } from 'graphql';
import { ApolloError } from 'apollo-server-express';
import { ArgumentValidationError } from 'type-graphql';
....ts
if (error && error.extensions) {
error.extensions.code = 'GRAPHQL_VALIDATION_FAILED';
}
....
return error; |
for newcommer from this toutorial u van add this import { GraphQLError, GraphQLFormattedError } from 'graphql';
import { ApolloError } from 'apollo-server-express';
import { ArgumentValidationError } from 'type-graphql';
const apolloserver = new ApolloServer({
schema, formatError: (error: GraphQLError): GraphQLFormattedError => {
if (error && error.extensions) {
error.extensions.code = 'GRAPHQL_VALIDATION_FAILED';
}
return error;
}
}); |
Following along with @benawad fantastic tutorial. On the validation video.
I'm running into an issue when attempting to use formatArgumentValidationError.
This is resulting in the TS error below
I haven't seen anyone else complain of this, so it feels like an issue with my setup. But I cannot for the life of me figure out why I am getting it while no one else is.
The text was updated successfully, but these errors were encountered: