So in the documents for the ruby gem shopify_api there is some framework code at:
https://github.com/Shopify/shopify-api-ruby/blob/main/docs/usage/session_storage.md
There is a skeleton initialize method, but what do I need to do in order to create a new instance of this class? [I am unfamiliar with the post 9.5.1 Rest libraries]
class CustomSessionStorage
include ShopifyAPI::Auth::SessionStorage
def initialize
# Initialize as needed
end
def store_session(session)
# Implement a store function
some_store_function(id: session.id, session_data: session.serialize)
end
def load_session(id)
# Implement a fetch function
session_data = some_fetch_function(id)
ShopifyAPI::Auth::Session.deserialize(session_data)
end
def delete_session(id)
# Implement a delete function
some_delete_function(id)
true
end
end
What sort of type for the session_data do I need in Postgresql? JSON? Something else?that
Is there some sort of table set up migration someone can share with me?
Obviously I don’t want in production to use the FileSessionStorage as in below:
ShopifyAPI::Context.setup(
api_key: "DUMMY",
api_secret_key: _app_token,
scope: "DUMMY",
host_name: "DUMMY",
private_shop: "#{@dev_shopname}.myshopify.com",
session_storage: ShopifyAPI::Auth::FileSessionStorage.new,
is_embedded: false,
is_private: true,
api_version: "2022-07"
)
This is for a private app, that might end up eventually as an AWS Lambda function, specifically to bulk update inventory using GraphQL, but I do need the Rest API as well for somethings as well. Thus I cannot use the Rails shopify_app gem but the shopify_api gem.
Any help, pointers on the Postgresql set up (particularly if I can use ActiveRecord, want to keep using Sinatra/Activerecord for migrations, etc.) would be appreciated as well as possibly notes/explanation of what I need to do in the skeleton methods for a production system.
Many thanks!