"Mutation" 类型字段的未知参数
Unknown argument on field of type "Mutation"
我正在研究 laravel、magento 和 graphql。我正在尝试使用突变来获取数据并发送到 api。但是
我遇到以下错误 -
{#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
}
]
}
]
}
这是我在 magento 中的 graphql -
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!
}
我用 laravel 调用它,比如 -
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);
}
}
还有这个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)
}
基本上,我将用户卡详细信息传递给 magento 并创建一个 post 请求。但是,我不确定为什么在我传递它时它会说未知参数。
您的变更需要一个名称为 input
类型为 PxFusionRequestData
的参数,但您正试图将所有子字段作为参数传递。试试这个:
mutation ($input: PxFusionRequestData) {
pxFusionPostRequest(input: $input)
}
我正在研究 laravel、magento 和 graphql。我正在尝试使用突变来获取数据并发送到 api。但是
我遇到以下错误 -
{#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
}
]
}
]
}
这是我在 magento 中的 graphql -
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!
}
我用 laravel 调用它,比如 -
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);
}
}
还有这个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)
}
基本上,我将用户卡详细信息传递给 magento 并创建一个 post 请求。但是,我不确定为什么在我传递它时它会说未知参数。
您的变更需要一个名称为 input
类型为 PxFusionRequestData
的参数,但您正试图将所有子字段作为参数传递。试试这个:
mutation ($input: PxFusionRequestData) {
pxFusionPostRequest(input: $input)
}