-
-
Notifications
You must be signed in to change notification settings - Fork 466
Description
I've done the validator with the rule-same [https://laravel.com/docs/8.x/validation#rule-same](rule same) and even if I put the same values or different values both time it fails.
Expected behavior/Solution
The rule same:XXXXinputXXX should be true if the input values match.
IMO, this can be a bug in my implementation (the way it's done in Validador class) or this is a bug from Laravel rule same or it's a bug from the @validator in Lighthouse.
Steps to reproduce
1.Create one input with multiple types and validator directive:
input CreateCarInput @validator {
name: String!
model: String!
color: String!
color_confirmation: String!
}2.Then create validator like php artisan lighthouse:validator CreateCarInputValidator and on the validator class add in rules():
public function rules(): array
{
return [
'color' => [
function ($attribute, $value, $fail) {
var_dump($value); //this is for debugg
var_dump($this->arg('color_confirmation')); //this is for debugg
}
],
'color_confirmation' => [
'same:color',// this is the rule
function ($attribute, $value, $fail) {
var_dump($value); //this is for debugg
var_dump($this->arg('color')); //this is for debugg
}
],
];
}3.Do the mutation like:
extend type Mutation {
createCar(input: CreateCarInput! @spread): Car! @create
}- Execute:
mutation {
createCar(input: {name: "xx", model: "xx", color: "xx", color_confirmation: "xx"}) {
id
}
}Output/Logs
Click to expand
string(2) "xx"
string(2) "xx"
string(2) "xx"
string(2) "xx"
{"errors":[{"message":"Validation failed for the field [createCar].","extensions":{"validation":{"input.color_confirmation":["The input.color confirmation and color must match."]},"category":"validation"},"locations":[{"line":2,"column":3}],"path":["createCar"],"trace":[{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\ArgTraversalDirective.php","line":32,"call":"Nuwave\\Lighthouse\\Validation\\ValidateDirective::Nuwave\\Lighthouse\\Validation\\{closure}(null, array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\TrimDirective.php","line":59,"call":"Nuwave\\Lighthouse\\Schema\\Directives\\ArgTraversalDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(null, array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Schema\\Factories\\FieldFactory.php","line":92,"call":"Nuwave\\Lighthouse\\Schema\\Directives\\TrimDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(null, array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":624,"call":"Nuwave\\Lighthouse\\Schema\\Factories\\FieldFactory::Nuwave\\Lighthouse\\Schema\\Factories\\{closure}(null, array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":554,"call":"GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, null, instance of GraphQL\\Type\\Definition\\ResolveInfo)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":474,"call":"GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Mutation, null, instance of ArrayObject(1), array(1))"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":858,"call":"GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(array(0), 'createCar')"},{"call":"GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(array(0), 'createCar')"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":860,"function":"array_reduce(array(1), instance of Closure, array(0))"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":490,"call":"GraphQL\\Executor\\ReferenceExecutor::promiseReduce(array(1), instance of Closure, array(0))"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":263,"call":"GraphQL\\Executor\\ReferenceExecutor::executeFieldsSerially(GraphQLType: Mutation, null, array(0), instance of ArrayObject(1))"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php","line":215,"call":"GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\Executor\\Executor.php","line":156,"call":"GraphQL\\Executor\\ReferenceExecutor::doExecute()"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php","line":169,"call":"GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php","line":102,"call":"GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php","line":234,"call":"GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php","line":141,"call":"Nuwave\\Lighthouse\\GraphQL::executeQuery(instance of GraphQL\\Language\\AST\\DocumentNode, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php","line":121,"call":"Nuwave\\Lighthouse\\GraphQL::executeOperation(instance of GraphQL\\Server\\OperationParams)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Support\\Utils.php","line":97,"call":"Nuwave\\Lighthouse\\GraphQL::Nuwave\\Lighthouse\\{closure}(instance of GraphQL\\Server\\OperationParams)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php","line":123,"call":"Nuwave\\Lighthouse\\Support\\Utils::applyEach(instance of Closure, instance of GraphQL\\Server\\OperationParams)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Controllers\\GraphQLController.php","line":29,"call":"Nuwave\\Lighthouse\\GraphQL::executeRequest(instance of Illuminate\\Http\\Request, instance of Laragraph\\Utils\\RequestParser, instance of GraphQL\\Server\\Helper)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php","line":48,"call":"Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::__invoke(instance of Illuminate\\Http\\Request, instance of Nuwave\\Lighthouse\\GraphQL, instance of Illuminate\\Events\\Dispatcher, instance of Laragraph\\Utils\\RequestParser, instance of GraphQL\\Server\\Helper, instance of Nuwave\\Lighthouse\\Execution\\SingleResponse)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php","line":239,"call":"Illuminate\\Routing\\ControllerDispatcher::dispatch(instance of Illuminate\\Routing\\Route, instance of Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController, '__invoke')"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php","line":196,"call":"Illuminate\\Routing\\Route::runController()"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php","line":685,"call":"Illuminate\\Routing\\Route::run()"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":128,"call":"Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AttemptAuthentication.php","line":32,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AttemptAuthentication::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AcceptJson.php","line":27,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":103,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php","line":687,"call":"Illuminate\\Pipeline\\Pipeline::then(instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php","line":662,"call":"Illuminate\\Routing\\Router::runRouteWithinStack(instance of Illuminate\\Routing\\Route, instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php","line":628,"call":"Illuminate\\Routing\\Router::runRoute(instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Route)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php","line":617,"call":"Illuminate\\Routing\\Router::dispatchToRoute(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php","line":165,"call":"Illuminate\\Routing\\Router::dispatch(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":128,"call":"Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php","line":21,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php","line":21,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php","line":27,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php","line":63,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php","line":57,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Fruitcake\\Cors\\HandleCors::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\fideloper\\proxy\\src\\TrustProxies.php","line":57,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":167,"call":"Fideloper\\Proxy\\TrustProxies::handle(instance of Illuminate\\Http\\Request, instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php","line":103,"call":"Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php","line":140,"call":"Illuminate\\Pipeline\\Pipeline::then(instance of Closure)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php","line":109,"call":"Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\public\\index.php","line":55,"call":"Illuminate\\Foundation\\Http\\Kernel::handle(instance of Illuminate\\Http\\Request)"},{"file":"C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\server.php","line":21,"function":"require_once('C:\\Users\\Pc-Francisco\\Desktop\\Git pages- Repo\\laravel-docs\\laravel_lighthouse_firecamp\\public\\index.php')"}]}]}
Lighthouse Version
5.3
My repo for testing purpose
https://github.com/FranciscoCaldeira/laravel_lighthouse_firecamp