This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "graphql" | |
gem "sqlite3" | |
gem "activerecord" | |
end | |
# Set up the database for the example | |
require "active_record" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a demonstration for using GraphQL-Enterprise's ObjectCache | |
# along with GraphqlDevise. | |
# | |
# The trick is that, by default, GraphqlDevise provides its own query type | |
# which uses its own BaseField. So, to mix in `GraphQL::Enterprise::ObjectCache::FieldIntegration`, | |
# you have to make your own BaseField class and include GraphqlDevise's `FieldAuthentication` module, | |
# then do the "existing schema" setup as described here: | |
# https://github.com/graphql-devise/graphql_devise/tree/master?tab=readme-ov-file#mounting-operations-in-an-existing-schema | |
# | |
require "bundler/inline" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "graphql", "2.3.16" | |
gem "graphql-enterprise", "1.5.2", source: "https://gems.graphql.pro" | |
end | |
class MySchema < GraphQL::Schema | |
class MakeInputsRequired < GraphQL::Enterprise::Changeset | |
release "2024-01-01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "graphql" | |
end | |
class MySchema < GraphQL::Schema | |
class BaseField < GraphQL::Schema::Field | |
def initialize(*args, camelize: false, **kwargs, &block) | |
super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This module will add a method | |
# to remove unsubscribed subscriptions: | |
module RemoveUnsubscribedSubscriptionsExtension | |
def remove_unsubscribed | |
all_topics, _topics_count = topics(limit: nil, offset: nil) | |
all_topics.each do |topic| | |
active_ids = [] | |
# This method will remove any subscriptions where are listed by the topic | |
# but not actually present in the DB (if this happens, it's a data consistency issue) | |
each_subscription_id(topic.name) do |id| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GraphQL-Ruby's connection system automatically adds first, last, after and before arguments. | |
# If you don't want all of those, you have to disable the system with `connection: false` | |
# in the field definition, then re-enable it manually. | |
# | |
# In this case, to create a field without the `last` argument, I created a custom subclass of `ConnectionExtension` | |
# which doesn't add any arguments. Then I add the specific arguments I want in the field definition. | |
# (I could also add those arguments in `def apply` using `field.argument ...`.) | |
require "bundler/inline" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "graphql", "2.3.7" | |
gem "sqlite3", "~>1.4" | |
gem "activerecord", require: "active_record" | |
end | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Schema.define do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "graphql", "2.3.7" | |
gem "sqlite3", "~>1.4" | |
gem "activerecord", require: "active_record" | |
end | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Schema.define do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "racc" | |
# gem "graphql", "2.0.16" | |
gem "graphql", "2.2.3" | |
end | |
class MySchema < GraphQL::Schema | |
class Query < GraphQL::Schema::Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
gem "graphql", "2.3.4" | |
gem "graphql-pro", "1.27.5" | |
gem "cancancan", "3.5.0" | |
end | |
class Ability | |
include CanCan::Ability |
NewerOlder