Skip to content

Instantly share code, notes, and snippets.

@kuro-kuroite
Created January 15, 2023 07:49
Show Gist options
  • Save kuro-kuroite/53d4e5c5989e64e270817b8e13b98c17 to your computer and use it in GitHub Desktop.
Save kuro-kuroite/53d4e5c5989e64e270817b8e13b98c17 to your computer and use it in GitHub Desktop.

タスク「商品の詳細ページ実装」

ここに Wrike や、Jira, Asana にあるタスク内容が書かれている

  • 概要
  • 背景
  • 実現したいこと
    • UI(like Figma)
    • データ
  • ...

[ヒアリング] 必要なデータや制約

  • ある id をもつ商品データ
    • id
    • name
    • color
    • publishAt
  • id はuuid
  • Not Found の場合、「見つかりませんでした」を表示すること

[ゴール] 提案する API のスキーマ

scalar DateTime

"""
query product (商品) の入力データ
"""
input ProductInput {
  id: ID!
}

"""
query product (商品) の出力データ
"""
type ProductPayload implements Node {
  """
  商品id
  """
  id: ID!
  """
  商品名
  """
  name: String!
  """
  商品の色
  """
  color: String!
  """
  商品の発売日
  """
  publishAt: DateTime!
  createAt: DateTime!
  updatedAt: DateTime!
}

"""
商品が見つからないエラー
"""
type NotFoundProductError implements Error {
  message: String!
  path: String!
  suggestion: String!
}

"""
query product (商品) の出力パターン
"""
union ProductResult = NotFoundProductError | ProductPayload

type Query {
  product(input: ProductInput!): ProductResult!
  # products(first: Int!, after: String!, last: Int!, before: String!, input: ProductsInput!): ProductConnection!
}

# """
# query products (商品リスト) の入力データ
# """
# input ProductsInput {
#   """
#   検索文字列
# 
#   検索条件: name の前方一致のみ
#   """
#   query: String
#   """
#   発売しているものだけにするか
# 
#   default: false
#   """
#   isPublish: Boolean
# }
# 
# """
# ページネーションデータ
# """
# type PageInfo {
#   hasNextPage: Boolean!
#   hasPreviousPage: Boolean!
#   startCursor: String
#   endCursor: String
# }
# 
# """
# 商品の出力データである節点(node) を持つ枝(edge)データ
# """
# type ProductEdge implements Edge {
#   """
#   商品の出力データ
#   """
#   node: ProductPayload!
#   cursor: ID!
# }
# 
# """
# query products (商品リスト) のページネーション付き出力データ
# """
# type ProductConnection implements Connection {
#   edges: [ProductEdge!]!
#   pageInfo: PageInfo!
#   totalCount: Int!
# }
# 
"""
エラーインターフェース
"""
interface Error {
  """
  エラーメッセージ
  """
  message: String!
  """
  エラー箇所
  """
  path: String!
  """
  エラー改善提案
  """
  suggestion: String!
}
# 
# """
# コネクションインターフェース
# 
# グラフ理論での連結(connection)
# """
# interface Connection {
#   """
#   節点(node) を持つ枝リスト(edges)
#   """
#   edges: [Edge!]!
#   """
#   ページネーションデータ
#   """
#   pageInfo: PageInfo!
#   """
#   edges の個数
#   """
#   totalCount: Int!
# }
# 
# """
# エッジインターフェース
# 
# グラフ理論での枝(edge)
# """
# interface Edge {
#   """
#   節点(node) == 出力データ
#   """
#   node: Node!
#   """
#   node の uuid ポインタ
#   """
#   cursor: ID!
# }
# 
"""
ノードインターフェース

グラフ理論での節点(node) == 出力データ
"""
interface Node {
  """
  uuid 形式
  """
  id: ID!
}

ex.

product: {
  uuid: '11111-111111111-11111',
  name: 'iPhone SE2',
  color: '黒',
  publishAt: '2022-01-01 00:00:00Z',
  createAt: '2022-01-01 00:00:00Z',
  updatedAt: '2022-01-01 00:00:00Z',
}

product: {
  message: '見つかりませんでした',
  suggesion: 'id が正しいのかを確認してください',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment