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

apidoc #2

Open
tmk3s opened this issue Nov 19, 2023 · 1 comment
Open

apidoc #2

tmk3s opened this issue Nov 19, 2023 · 1 comment

Comments

@tmk3s
Copy link
Owner

tmk3s commented Nov 19, 2023

コマンド: ./node_modules/.bin/graphql-markdown http://0.0.0.0:8080/graphql > schema.md

Schema Types

Table of Contents

Query

Field Argument Type Description
company Company

Find a employee by ID

id ID!
employee Employee

Find a employee by ID

id ID!
employees [Employee!]!
testField String!

An example field added by the generator

Mutation

Field Argument Type Description
testField String!

An example field added by the generator

updateComapny UpdateCompanyPayload
input UpdateCompanyInput!

Parameters for UpdateCompany

Objects

Company

会社マスタ

Field Argument Type Description
address String!

住所

building String!

建物名

createdAt String!

作成日

id ID!
name String!

名前

postCode1 String!

郵便番号1

postCode2 String!

郵便番号2

prefectureId ID!

都道府県ID

prefectureName String!

都道府県

updatedAt String!

更新日

Employee

従業員

Field Argument Type Description
birthday String

誕生日

code String!

従業員番号

companyId ID!

会社ID

createdAt String!

作成日

employeeAddress EmployeeAddress
employeeBanks [EmployeeBank!]
employeeFamilies [EmployeeFamily!]
employeePayrollGroups [EmployeePayrollGroup!]
employeeQualifications [EmployeeQualification!]
employeeSalaries [EmployeeSalary!]
firstName String!

firstNameKana String

名(カナ)

gender Gender

性別

id ID!
image String

画像

introduction String

自己紹介

joinedOn String

入社日

lastName String!

lastNameKana String

姓(カナ)

retirementOn String

退社日

updatedAt String!

更新日

EmployeeAddress

従業員住所

Field Argument Type Description
address String!

住所

building String!

建物名

companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

id ID!
postCode1 String!

郵便番号1

postCode2 String!

郵便番号2

prefectureId ID!

都道府県ID

updatedAt String!

更新日

EmployeeBank

従業員口座

Field Argument Type Description
bankBranchId ID!

銀行支店ID

bankId ID!

銀行ID

bankNumber String!

口座番号

companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

id ID!
rowNo Int!

行No

updatedAt String!

更新日

EmployeeFamily

従業員家族

Field Argument Type Description
birthday String

誕生日

companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

firstName String!

firstNameKana String!

名(カナ)

gender [Gender!]

性別

id ID!
lastName String!

lastNameKana String!

姓(カナ)

relationship [Relationship!]!

続柄

rowNo Int!

行No

updatedAt String!

更新日

EmployeePayrollGroup

従業員の給与グループ

Field Argument Type Description
companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

id ID!
payrollGroupId ID!

給与グループID

updatedAt String!

更新日

EmployeeQualification

従業員資格情報

Field Argument Type Description
acquisitionAt String!

取得日

companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

id ID!
qualificationId ID!

資格ID

updatedAt String!

更新日

EmployeeSalary

従業員給与

Field Argument Type Description
companyId ID!

会社ID

createdAt String!

作成日

deductiblePaymentAmount Int!

差引支給額

employeeId ID!

従業員ID

employeeSalaryAttendanceItems [EmployeeSalaryAttendanceItem!]
employeeSalaryDeductionItems [EmployeeSalaryDeductionItem!]
employeeSalaryPaymentItems [EmployeeSalaryPaymentItem!]
id ID!
isConfirm Boolean!

確定フラグ

paymentDate String!

支給日

payrollGroupId ID!

給与グループID

totalDeduction Int!

控除合計

totalPayment Int!

支給合計

updatedAt String!

更新日

EmployeeSalaryAttendanceItem

従業員給与の勤怠項目

Field Argument Type Description
attendanceItemId ID!

勤怠項目ID

companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

id ID!
isDelete Boolean!

削除フラグ

name String!

項目名

rowNo Int!

行No

updatedAt String!

更新日

value String!

EmployeeSalaryDeductionItem

従業員給与の控除項目

Field Argument Type Description
calculationProcessFile String

計算過程のファイル

companyId ID!

会社ID

createdAt String!

作成日

deductionItemId ID!

控除項目ID

employeeId ID!

従業員ID

formula String

計算式

id ID!
isDelete Boolean!

削除フラグ

isMinus Boolean!

マイナスフラグ

itemType [ItemType!]!

項目種別

name String!

項目名

rowNo Int!

行No

settingType [ItemType!]!

金額設定種別

updatedAt String!

更新日

value String!

EmployeeSalaryPaymentItem

従業員給与の支給項目

Field Argument Type Description
calculationProcessFile String

計算過程のファイル

companyId ID!

会社ID

createdAt String!

作成日

employeeId ID!

従業員ID

formula String

計算式

id ID!
isDelete Boolean!

削除フラグ

isMinus Boolean!

マイナスフラグ

itemType [ItemType!]!

項目種別

name String!

項目名

paymentItemId ID!

支給項目ID

rowNo Int!

行No

settingType [ItemType!]!

金額設定種別

updatedAt String!

更新日

value String!

UpdateCompanyPayload

Autogenerated return type of UpdateCompany.

Field Argument Type Description
clientMutationId String

A unique identifier for the client performing the mutation.

errors [String!]!

Inputs

UpdateCompanyInput

Autogenerated input type of UpdateCompany

Field Type Description
clientMutationId String

A unique identifier for the client performing the mutation.

id ID!
name String!
postCode1 String!
postCode2 String!
prefectureId ID!
address String!
building String!

Enums

Gender

Value Description
male

female

ItemType

Value Description
health

健康保険

nursing

介護保険

pension

厚生年金

child

子供手当

customize

カスタマイズ

Relationship

Value Description
husband

wife

older_brother

younger_brother

sister

younger_sister

grandfather

祖父

grandmother

祖母

Scalars

Boolean

Represents true or false values.

ID

Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.

Int

Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

String

Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text.

@tmk3s
Copy link
Owner Author

tmk3s commented Nov 19, 2023

mutation updateCompany($companyId: ID!, $UpdateCompanyInput: UpdateCompanyInput!){
  updateCompany(id: $companyId, updateCompanyInput: $UpdateCompanyInput) {
    id
    name
  }
}
{
  "errors": [
    {
      "message": "Field 'updateCompany' doesn't exist on type 'Mutation'",
      "locations": [
        {
          "line": 6,
          "column": 3
        }
      ],
      "path": [
        "mutation updateCompany",
        "updateCompany"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Mutation",
        "fieldName": "updateCompany"
      }
    },
    {
      "message": "Variable $companyId is declared by updateCompany but not used",
      "locations": [
        {
          "line": 5,
          "column": 1
        }
      ],
      "path": [
        "mutation updateCompany"
      ],
      "extensions": {
        "code": "variableNotUsed",
        "variableName": "companyId"
      }
    },
    {
      "message": "Variable $UpdateCompanyInput is declared by updateCompany but not used",
      "locations": [
        {
          "line": 5,
          "column": 1
        }
      ],
      "path": [
        "mutation updateCompany"
      ],
      "extensions": {
        "code": "variableNotUsed",
        "variableName": "UpdateCompanyInput"
      }
    }
  ]
}

完成形

app/graphql/types/mutation_type.rb
# frozen_string_literal: true

module Types
  class MutationType < Types::BaseObject
    # TODO: remove me
    field :test_field, String, null: false,
      description: "An example field added by the generator"
    def test_field
      "Hello World"
    end

    field :update_comapny, mutation: Mutations::UpdateCompany
  end
end

app/graphql/mutations/update_company.rb
class Mutations::UpdateCompany < Mutations::BaseMutation
  argument :id, ID
  argument :name, String
  argument :post_code1, String
  argument :post_code2, String
  argument :prefecture_id, ID
  argument :address, String
  argument :building, String

  field :errors, [String], null: false

  def resolve(id:, name:, post_code1:, post_code2:, prefecture_id:, address:, building:)
    company = Company.find(id)
    company.assign_attributes(id:, name:, post_code1:, post_code2:, prefecture_id:, address:, building:)
    if company.save
      # Successful creation, return the created object with no errors
      {
        errors: [],
      }
    else
      # Failed save, return the errors to the client
      {
        errors: company.errors.full_messages
      }
    end
  end
end

これに対するクエリは下記のようにする
スクリーンショット 2023-11-19 21 24 12

mutation updateComapny($UpdateCompanyInput: UpdateCompanyInput!){
  updateComapny(input: $UpdateCompanyInput) {
    errors
  }
}

{
  "UpdateCompanyInput": {
    "id": "12",
    "name": "name1",
    "postCode1": "939",
    "postCode2": "0627",
    "prefectureId": "5",
    "address": "テスト",
    "building": "データ"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant