我如何在graphql中的模型中分离枚举类型

问题描述

以下是我的 rails 应用程序中的预订模型和我在 graphql 中的预订类型,我只想为模型枚举创建单独的类型。请指导我如何执行此操作以及如何查询枚举。如果缺少任何细节,请告诉我。

我的 rails app.models/booking.rb (model) 中的枚举

enum booking_type: { delivery: 'delivery',appointment: 'appointment' }
  enum vaccination_status: { first_dose: 'first_dose',second_dose: 'second_dose',nothing: 'nothing' }
  enum sex: { male: 'male',female: 'female' }
  enum booking_status: {
    pending: 'pending',to_follow_up: 'to_follow_up',kit_sent_test_done: 'kit_sent_test_done',lab_updated: 'lab_updated',approved: 'approved',published: 'published',rejected: 'rejected',day_8_remaining:
      'day_8_remaining'
  }
  enum type_of_transport: {
    airplane: 'airplane',bus_car: 'bus_car',vassel_boat: 'vassel_boat',train: 'train'
  }

app/graphql/types/booking_type.rb

module Types
    class BookingType < Types::BaSEObject
   
        field :booking_type,String,null: true
        field :booking_number,null: true
        field :first_name,null: true
        field :last_name,null: true
        field :date_of_birth,null: true
        field :sex,null: true
        field :vaccination_status,null: true
        field :ethnicity,null: true
        field :nhs_number,null: true
        field :passport_number,null: true
        field :postcode,null: true
        field :address,null: true
        field :city,null: true
        field :departure_date,null: true
        field :arrival_date_in_uk,null: true
        field :country_travel_from,null: true
        field :city_travel_from,null: true
        field :type_of_transport,null: true
        field :flight,null: true
        field :nationality,null: true
        field :list_of_all_departed_countries,null: true
        field :email,null: true
        field :telephone_number,null: true
        field :additional_notes,null: true
        field :booking_tracking_code,null: true
        # field :booking_status,null: true
        field :day_two_kit_bar_code,null: true
        field :day_five_kit_bar_code,null: true
        field :day_eight_kit_bar_code,null: true
        field :day_two_pin_code,null: true
        field :day_five_pin_code,null: true
        field :day_eight_pin_code,null: true
        field :day_eight_tracking_code,null: true
        field :day_five_tracking_code,null: true
        field :day_two_tracking_code,null: true
        field :testing_center_id,Integer,null: true
        field :product_id,null: true
        field :order_id,null: true
        field :created_at,null: true
        field :updated_at,null: true
        field :departure_time,null: true
        field :region,null: true
        field :response,null: true
        field :fit_to_fly_bar_code,null: true
        field :fit_to_fly_pin_code,null: true
        field :fit_to_fly_tracking_code,null: true
        field :external_token,null: true
        field :booking_date,null: true
        field :kit_track,null: true
    end
end

app/graphql/types/booking_enums_types.rb

class Types::BookingEnums < Types::BaseEnum
    value "delivery",value: :delivery
    value "appointment",value: :appointment
    value "first_dose",value: :first_dose
    value "second_dose",value: :second_dose
    value "nothing",value: :nothing
    value "male",value: :male
    value "female",value: :female
    value "pending",value: :pending
    value "to_follow_up",value: :to_follow_up
    value "kit_sent_test_done",value::kit_sent_test_done
    value "lab_updated",value::lab_updated
    value "approved",value::approved
    value "published",value::published
    value "rejected",value::rejected
    value "day_8_remaining",value::day_8_remaining
    value "airplane",value::airplane
    value "bus_car",value::bus_car
    value "vassel_boat",value::vassel_boat
    value "train",value::train
  end

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...