How can I serve a non Active Record Data on Rails Api with GraphQL?

Viewed 24

I have a rails api that serves to React Native and React frontends and it serves all the data from ActiveRecord as it's supposed to do but I can't seem to find a proper tutorial how to serve a non ActiveRecord data from a rails api.

Data is extremely simple, literally just four different strings as I don't want to hardcode this to frontend.

So far this is what I have.

In app>graphql>types>address_type.rb

module Types
  class AddressType < BaseObject
    field :name, String, null: false
  end
end

In app>graphql>types>query_type.rb

field :address_types, Types::AddressType, null: true

    def address_types
      [
        {name:"Pickup Address"},
        {name:"Delivery Address"},
        {name:"Event Address"},
        {name:"Shipping Address"},
      ]
    end
0 Answers
Related