Skip to content
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

Variablesを利用しないで引数を指定した場合に出荷日の登録ができない #77

Closed
okazy opened this issue Aug 3, 2020 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@okazy
Copy link
Contributor

okazy commented Aug 3, 2020

Variablesを利用しないで引数を指定した場合に出荷日の登録ができない不具合があります。

文字列から DataTime へは DateTimeType::parseValue() で変換しています。

public function parseValue($value)
{
$dateTime = DateTime::createFromFormat(DateTime::ATOM, $value);
if ($dateTime) {
return $dateTime;
} else {
throw new InvalidArgumentException('DateTime parse error, please specify in "Y-m-d\TH:i:sP".'.Utils::printSafe($value));
}
}

Mutationのリゾルバ内で引数を利用していますが、リゾルバ実行時点で文字列のまま引数が渡される場合があります。
リクエストの引数の指定の方法の違いでこちらの処理を通らないで文字列のまま場合があるようです。

public function updateShipped($root, $args)

引数を直接指定する場合

mutation UpdateShipped {
  updateShipped (
    id: 1,
    shipping_date: "2020-05-18T12:57:08+09:00"
  ) {
    id
    shipping_date
  }
}

こちらの場合はリゾルバ実行時点で $args から文字列が取得できます。

引数をvariablesで指定する場合

mutation UpdateShipped (
  $shipping_date: DateTime
){
  updateShipped (
    id: 99,
    shipping_date: $shipping_date
  ) {
    id
    shipping_date
  }
}
{
  "shipping_date": "2020-05-18T12:57:08+09:00"
}

こちらの場合はリゾルバ実行時点で $args から DateTime が取得できます。

リゾルバで文字列か DateTime か調べることで回避できますが、他のクエリでも起こり得ることかと思いますので、原因の追究はしておきたいです。

@okazy okazy added the bug Something isn't working label Aug 3, 2020
@okazy okazy added this to the 1.0 milestone Aug 3, 2020
@okazy
Copy link
Contributor Author

okazy commented Aug 3, 2020

GraphQLのドキュメントを読んでみましたが、Variablesを利用するかどうかで挙動の違いについての記載はありませんでした。
https://graphql.org/learn/queries/

いったん、文字列がきても DateTime がきても問題がないように修正しようと思います。

@okazy
Copy link
Contributor Author

okazy commented Aug 4, 2020

#80 で修正されました。

@okazy okazy closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant