Module: ActiveShopifyGraphQL::GraphQLAssociations

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_shopify_graphql/graphql_associations.rb

Overview

Allows ActiveRecord (or duck-typed) objects to define associations to GraphQL objects This module bridges the gap between local database records and remote Shopify GraphQL data

Examples:

class Reward < ApplicationRecord
  include ActiveShopifyGraphQL::GraphQLAssociations

  belongs_to_graphql :customer
  has_many_graphql :variants, class: "ProductVariant", query_name: "productVariants"
end

reward = Reward.first
customer = reward.customer # => ActiveShopifyGraphQL::Customer instance
variants = reward.variants(first: 10) # => Array of ProductVariant instances