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" }, |
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 Schema < GraphQL::Schema | |
# In your base field class, create a new field extension | |
# and configure your fields to use that one instead of GraphQL-Ruby's default. |
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 "libev_scheduler" | |
end | |
class MySchema < GraphQL::Schema | |
class FetchThings < GraphQL::Dataloader::Source | |
def initialize(starting_at:) |
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.0.24" | |
end | |
class MySchema < GraphQL::Schema | |
module CustomIntrospection | |
module HideIntrospectionByContext | |
def visible?(ctx) |
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 benchmark aims to test GraphQL-Ruby's runtime performance | |
# _except_ for parsing. | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
# Pick a GraphQL version: | |
# gem "graphql", "1.13.19" | |
gem "graphql", "~>2.0" | |
gem "benchmark-ips" |
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", path: "./" | |
gem "graphql-enterprise", source: "https://gems.graphql.pro" | |
end | |
class BaseField < GraphQL::Schema::Field | |
include GraphQL::Enterprise::Changeset::FieldIntegration | |
end |
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.11.2" | |
end | |
class Schema < GraphQL::Schema | |
class Error < GraphQL::Schema::Object | |
field :message, String, null: false | |
end |
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
import { Client, defaultExchanges, subscriptionExchange } from 'urql' | |
import Pusher from "pusher" | |
const pusherClient = new Pusher("your-app-key", { cluster: "us2" }) | |
const forwardSubscriptionToPusher = (operation) => { | |
// urql will call `.subscribe` on the returned object: | |
// https://github.com/FormidableLabs/urql/blob/f89cfd06d9f14ae9cb3be10b21bd5cbd12ca275c/packages/core/src/exchanges/subscription.ts#L68-L73 | |
// https://github.com/FormidableLabs/urql/blob/f89cfd06d9f14ae9cb3be10b21bd5cbd12ca275c/packages/core/src/exchanges/subscription.ts#L82-L97 | |
return { | |
subscribe: ({next, error, complete}) => { |
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.0" | |
end | |
# This visitor will inline any fragment definitions in the document. | |
# It assumes that the document is valid; it will :boom: if there are | |
# cycles in the fragment spreads. |
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.13.10" | |
gem "graphql-pro", "1.21.4" | |
gem "graphql-enterprise", "1.1.3" | |
end | |
class CachingSchema < GraphQL::Schema |