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
# In this approach `nodes` are removed from a connection _after_ pagination has been applied. | |
# | |
# This approach has some downsides: | |
# - It may leak data about unauthorized nodes. hasNextPage and hasPrevPage will | |
# indicate that items were removed from the list; depending on sort and filter options, | |
# a client could learn about the attributes of the removed nodes. | |
# - pagination metadata may be wrong, since the list of nodes was modified after it was calculated. | |
# (some pagination info may be calculated _while_ the list of nodes is prepared.) | |
# | |
# The best alternative approach is to use `scope_items` instead, but I share this |
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", "1.12.17" | |
# gem "graphql", "1.12.18" | |
end | |
class MySchema < GraphQL::Schema | |
class Model < GraphQL::Schema::Object | |
field :name, String, null: false |
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.2.6" | |
end | |
class MySchema < GraphQL::Schema | |
class Undocumented < GraphQL::Schema::Directive | |
locations(FIELD_DEFINITION, INPUT_FIELD_DEFINITION) | |
description "This should be removed our generated docs" |
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.2.6" | |
end | |
class NewSchema < GraphQL::Schema | |
class Query < GraphQL::Schema::Object | |
field :old_field, Integer | |
def old_field = 1 |
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", "1.12.24" | |
end | |
# Newer graphql-ruby versions have `context.repsonse_extensions` which automatically | |
# adds data to the result["extensions"] field. But for 1.12, you have to add it manually. | |
# @see https://graphql-ruby.org/queries/response_extensions.html | |
class MySchema < GraphQL::Schema |
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 "concurrent-ruby" | |
end | |
class MySchema < GraphQL::Schema | |
# This source assumes that each record requires an expensive database query of its *own*. | |
# If that's not the case, then remove `def initialize` below |
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", "1.12.24" | |
gem "graphql-pro", "1.24.15" | |
end | |
class Schema < GraphQL::Schema | |
class Thing < GraphQL::Schema::Object | |
field :name, String, null: false |
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", "1.12.18" | |
gem "graphql-pro", "1.24.13" | |
gem "graphql-batch" | |
end | |
# Monkey-patch this to avoid deleting keys from multiplex.context | |
# in the ensure block below. |
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.1.6" | |
end | |
class MySchema < GraphQL::Schema | |
class Query < GraphQL::Schema::Object | |
field :f1, Int | |
field :f2, Int |
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 | |
# Here's a pretend DB with three tenants: | |
DATA = { | |
"food_lion" => [ | |
{ id: 1, name: "Mayo" }, |
NewerOlder