I am working on laravel, magento and graphql. I am trying use mutation to grab a data and send to api. But
I am getting below errors -
{#321
+"errors": array:8 [
0 => {#301
+"message": "Unknown argument "card_num" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#304
+"category": "graphql"
}
+"locations": array:1 [
0 => {#307
+"line": 2
+"column": 25
}
]
}
1 => {#305
+"message": "Unknown argument "nme_card" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#259
+"category": "graphql"
}
+"locations": array:1 [
0 => {#302
+"line": 2
+"column": 46
}
]
}
2 => {#292
+"message": "Unknown argument "ex_mnth" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#291
+"category": "graphql"
}
+"locations": array:1 [
0 => {#294
+"line": 2
+"column": 67
}
]
}
3 => {#306
+"message": "Unknown argument "ex_yr" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#299
+"category": "graphql"
}
+"locations": array:1 [
0 => {#308
+"line": 2
+"column": 86
}
]
}
4 => {#309
+"message": "Unknown argument "cvc2" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#310
+"category": "graphql"
}
+"locations": array:1 [
0 => {#311
+"line": 2
+"column": 101
}
]
}
5 => {#312
+"message": "Unknown argument "action" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#313
+"category": "graphql"
}
+"locations": array:1 [
0 => {#314
+"line": 2
+"column": 114
}
]
}
6 => {#315
+"message": "Unknown argument "dps_px_pay" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#316
+"category": "graphql"
}
+"locations": array:1 [
0 => {#317
+"line": 2
+"column": 131
}
]
}
7 => {#318
+"message": "Unknown argument "session_id" on field "pxFusionPostRequest" of type "Mutation"."
+"extensions": {#319
+"category": "graphql"
}
+"locations": array:1 [
0 => {#320
+"line": 2
+"column": 156
}
]
}
]
}
Here is my graphql in magento -
type Mutation {
pxFusionPostRequest(input: PxFusionRequestData): String @resolver(class: "Limesharp\\Windcave\\Model\\Resolver\\PxFusionPostRequest")
}
input PxFusionRequestData {
card_num: String!
nme_card: String!
ex_mnth: String!
ex_yr: String!
cvc2: String!
action: String!
dps_px_pay: String!
session_id: String!
}
And I calling it using laravel like -
public function pxFusionPostRequest($input){
try {
$response = $this->sendGraphQL('post', 'queries/payment/px-fusion-post-request.graphql', [
'card_num' => $input['cardNum'],
'nme_card' => $input['nmeCard'],
'ex_mnth' => $input['exMnth'],
'ex_yr' => $input['exYr'],
'cvc2' => $input['cvc2'],
'action' => $input['action'],
'dps_px_pay' => $input['dpsPxPay'],
'session_id' => $input['sessionId']
]);
dd($response);
if ($response->data->pxFusionPostRequest == null) {
throw new GraphQlLogicException($response->errors[0]->message);
}
$data = $response->data->pxFusionPostRequest;
return response()->json($data);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()])->setStatusCode(400);
}
}
And this px-fusion-post-request.graphql
mutation ($card_num: String!, $nme_card: String!, $ex_mnth: String!, $ex_yr: String!, $cvc2: String!, $action: String!, $dps_px_pay: String!, $session_id: String!) {
pxFusionPostRequest(card_num: $card_num, nme_card: $nme_card, ex_mnth: $ex_mnth, ex_yr: $ex_yr, cvc2: $cvc2, action: $action, dps_px_pay: $dps_px_pay, session_id: $session_id)
}
Basically, I am passing user card details to magento and creating a post request. But, I am not sure why it is saying unknown argument as I am passing it.
Your mutation is expecting one argument with name input
and type PxFusionRequestData
, but you are trying to pass all the subfields as parameters. Try this:
mutation ($input: PxFusionRequestData) {
pxFusionPostRequest(input: $input)
}