source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/introspection_system.rb | Ruby | mit | 5,430 | master | 4,952 | # frozen_string_literal: true
module GraphQL
class Schema
class IntrospectionSystem
attr_reader :types, :possible_types
def initialize(schema)
@schema = schema
@class_based = !!@schema.is_a?(Class)
@built_in_namespace = GraphQL::Introspection
@custom_namespace = if @cl... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/build_from_definition.rb | Ruby | mit | 5,430 | master | 25,382 | # frozen_string_literal: true
require "graphql/schema/build_from_definition/resolve_map"
module GraphQL
class Schema
module BuildFromDefinition
class << self
# @see {Schema.from_definition}
def from_definition(schema_superclass, definition_string, parser: GraphQL.default_parser, **kwargs)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/warden.rb | Ruby | mit | 5,430 | master | 23,991 | # frozen_string_literal: true
require 'set'
module GraphQL
class Schema
# Restrict access to a {GraphQL::Schema} with a user-defined `visible?` implementations.
#
# When validating and executing a query, all access to schema members
# should go through a warden. If you access the schema directly,
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/visibility.rb | Ruby | mit | 5,430 | master | 10,984 | # frozen_string_literal: true
require "graphql/schema/visibility/profile"
require "graphql/schema/visibility/migration"
require "graphql/schema/visibility/visit"
module GraphQL
class Schema
# Use this plugin to make some parts of your schema hidden from some viewers.
#
class Visibility
# @param sch... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/late_bound_type.rb | Ruby | mit | 5,430 | master | 888 | # frozen_string_literal: true
module GraphQL
class Schema
# A stand-in for a type which will be resolved in a given schema, by name.
# TODO: support argument types too, make this a public API somehow
# @api Private
class LateBoundType
attr_reader :name
alias :graphql_name :name
def i... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/field.rb | Ruby | mit | 5,430 | master | 42,378 | # frozen_string_literal: true
require "graphql/schema/field/connection_extension"
require "graphql/schema/field/scope_extension"
module GraphQL
class Schema
class Field
include GraphQL::Schema::Member::HasArguments
include GraphQL::Schema::Member::HasArguments::FieldConfigured
include GraphQL::... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/scalar.rb | Ruby | mit | 5,430 | master | 1,852 | # frozen_string_literal: true
module GraphQL
class Schema
class Scalar < GraphQL::Schema::Member
extend GraphQL::Schema::Member::ValidatesInput
class << self
def coerce_input(val, ctx)
val
end
def coerce_result(val, ctx)
val
end
def kind
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/enum_value.rb | Ruby | mit | 5,430 | master | 2,491 | # frozen_string_literal: true
module GraphQL
class Schema
# A possible value for an {Enum}.
#
# You can extend this class to customize enum values in your schema.
#
# @example custom enum value class
# # define a custom class:
# class CustomEnumValue < GraphQL::Schema::EnumValue
#... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/has_single_input_argument.rb | Ruby | mit | 5,430 | master | 5,353 | # frozen_string_literal: true
module GraphQL
class Schema
module HasSingleInputArgument
def resolve_with_support(**inputs)
if inputs[:input].is_a?(InputObject)
input = inputs[:input].to_kwargs
else
input = inputs[:input]
end
new_extras = field ? field.ex... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/unique_within_type.rb | Ruby | mit | 5,430 | master | 1,105 | # frozen_string_literal: true
require "base64"
module GraphQL
class Schema
module UniqueWithinType
class << self
attr_accessor :default_id_separator
end
self.default_id_separator = "-"
module_function
# @param type_name [String]
# @param object_value [Any]
# @r... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/wrapper.rb | Ruby | mit | 5,430 | master | 617 | # frozen_string_literal: true
module GraphQL
class Schema
class Wrapper
include GraphQL::Schema::Member::TypeSystemHelpers
# @return [Class, Module] The inner type of this wrapping type, the type of which one or more objects may be present.
attr_reader :of_type
def initialize(of_type)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/non_null.rb | Ruby | mit | 5,430 | master | 1,797 | # frozen_string_literal: true
module GraphQL
class Schema
# Represents a non null type in the schema.
# Wraps a {Schema::Member} when it is required.
# @see {Schema::Member::TypeSystemHelpers#to_non_null_type}
class NonNull < GraphQL::Schema::Wrapper
include Schema::Member::ValidatesInput
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/mutation.rb | Ruby | mit | 5,430 | master | 2,927 | # frozen_string_literal: true
module GraphQL
class Schema
# This base class accepts configuration for a mutation root field,
# then it can be hooked up to your mutation root object type.
#
# If you want to customize how this class generates types, in your base class,
# override the various `gener... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator.rb | Ruby | mit | 5,430 | master | 7,241 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# The thing being validated
# @return [GraphQL::Schema::Argument, GraphQL::Schema::Field, GraphQL::Schema::Resolver, Class<GraphQL::Schema::InputObject>]
attr_reader :validated
# @param validated [GraphQL::Schema::... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/resolver.rb | Ruby | mit | 5,430 | master | 19,840 | # frozen_string_literal: true
require "graphql/schema/resolver/has_payload_type"
module GraphQL
class Schema
# A class-based container for field configuration and resolution logic. It supports:
#
# - Arguments, via `.argument(...)` helper, which will be applied to the field.
# - Return type, via `.ty... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/printer.rb | Ruby | mit | 5,430 | master | 3,335 | # frozen_string_literal: true
module GraphQL
class Schema
# Used to convert your {GraphQL::Schema} to a GraphQL schema string
#
# @example print your schema to standard output (via helper)
# puts GraphQL::Schema::Printer.print_schema(MySchema)
#
# @example print your schema to standard outpu... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/ractor_shareable.rb | Ruby | mit | 5,430 | master | 2,818 | # frozen_string_literal: true
module GraphQL
class Schema
module RactorShareable
def self.extended(schema_class)
schema_class.extend(SchemaExtension)
schema_class.freeze_schema
end
module SchemaExtension
def freeze_error_handlers(handlers)
handlers[:subclass_h... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/finder.rb | Ruby | mit | 5,430 | master | 4,939 | # frozen_string_literal: true
module GraphQL
class Schema
# Find schema members using string paths
#
# @example Finding object types
# MySchema.find("SomeObjectType")
#
# @example Finding fields
# MySchema.find("SomeObjectType.myField")
#
# @example Finding arguments
# M... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/type_expression.rb | Ruby | mit | 5,430 | master | 1,609 | # frozen_string_literal: true
module GraphQL
class Schema
# @api private
module TypeExpression
# Fetch a type from a type map by its AST specification.
# Return `nil` if not found.
# @param type_owner [#type] A thing for looking up types by name
# @param ast_node [GraphQL::Language::No... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/field_extension.rb | Ruby | mit | 5,430 | master | 6,617 | # frozen_string_literal: true
module GraphQL
class Schema
# Extend this class to make field-level customizations to resolve behavior.
#
# When a extension is added to a field with `extension(MyExtension)`, a `MyExtension` instance
# is created, and its hooks are applied whenever that field is called.
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/base_64_encoder.rb | Ruby | mit | 5,430 | master | 535 | # frozen_string_literal: true
require "base64"
module GraphQL
class Schema
# @api private
module Base64Encoder
def self.encode(unencoded_text, nonce: false)
Base64.urlsafe_encode64(unencoded_text, padding: false)
end
def self.decode(encoded_text, nonce: false)
# urlsafe_deco... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/list.rb | Ruby | mit | 5,430 | master | 2,421 | # frozen_string_literal: true
module GraphQL
class Schema
# Represents a list type in the schema.
# Wraps a {Schema::Member} as a list type.
# @see Schema::Member::TypeSystemHelpers#to_list_type Create a list type from another GraphQL type
class List < GraphQL::Schema::Wrapper
include Schema::M... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/relay_classic_mutation.rb | Ruby | mit | 5,430 | master | 2,354 | # frozen_string_literal: true
module GraphQL
class Schema
# Mutations that extend this base class get some conventions added for free:
#
# - An argument called `clientMutationId` is _always_ added, but it's not passed
# to the resolve method. The value is re-inserted to the response. (It's for
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/type_membership.rb | Ruby | mit | 5,430 | master | 1,787 | # frozen_string_literal: true
module GraphQL
class Schema
# This class joins an object type to an abstract type (interface or union) of which
# it is a member.
class TypeMembership
# @return [Class<GraphQL::Schema::Object>]
attr_accessor :object_type
# @return [Class<GraphQL::Schema::U... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/build_from_definition/resolve_map.rb | Ruby | mit | 5,430 | master | 2,829 | # frozen_string_literal: true
require "graphql/schema/build_from_definition/resolve_map/default_resolve"
module GraphQL
class Schema
module BuildFromDefinition
# Wrap a user-provided hash of resolution behavior for easy access at runtime.
#
# Coerce scalar values by:
# - Checking for a fu... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb | Ruby | mit | 5,430 | master | 1,694 | # frozen_string_literal: true
module GraphQL
class Schema
module BuildFromDefinition
class ResolveMap
class DefaultResolve
def initialize(field_map, field_name)
@field_map = field_map
@field_name = field_name
end
# Make some runtime checks about... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/format_validator.rb | Ruby | mit | 5,430 | master | 1,456 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to assert that string values match (or don't match) the given RegExp.
#
# @example requiring input to match a pattern
#
# argument :handle, String, required: true,
# validates: { format:... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/numericality_validator.rb | Ruby | mit | 5,430 | master | 3,561 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to assert numerical comparisons hold true for inputs.
#
# @example Require a number between 0 and 1
#
# argument :batting_average, Float, required: true, validates: { numericality: { within: 0..1 }... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/allow_blank_validator.rb | Ruby | mit | 5,430 | master | 960 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to specifically reject values that respond to `.blank?` and respond truthy for that method.
#
# @example Require a non-empty string for an argument
# argument :name, String, required: true, validate: { ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/inclusion_validator.rb | Ruby | mit | 5,430 | master | 1,100 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# You can use this to allow certain values for an argument.
#
# Usually, a {GraphQL::Schema::Enum} is better for this, because it's self-documenting.
#
# @example only allow certain values for an argument
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/length_validator.rb | Ruby | mit | 5,430 | master | 2,533 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to enforce a `.length` restriction on incoming values. It works for both Strings and Lists.
#
# @example Allow no more than 10 IDs
#
# argument :ids, [ID], required: true, validates: { length: { m... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/exclusion_validator.rb | Ruby | mit | 5,430 | master | 962 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to specifically reject values from an argument.
#
# @example disallow certain values
#
# argument :favorite_non_prime, Integer, required: true,
# validates: { exclusion: { in: [2, 3, 5, ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/allow_null_validator.rb | Ruby | mit | 5,430 | master | 850 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to specifically reject or permit `nil` values (given as `null` from GraphQL).
#
# @example require a non-null value for an argument if it is provided
# argument :name, String, required: false, validates... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/required_validator.rb | Ruby | mit | 5,430 | master | 6,506 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this validator to require _one_ of the named arguments to be present.
# Or, use Arrays of symbols to name a valid _set_ of arguments.
#
# (This is for specifying mutually exclusive sets of arguments.)
#
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/validator/all_validator.rb | Ruby | mit | 5,430 | master | 1,877 | # frozen_string_literal: true
module GraphQL
class Schema
class Validator
# Use this to validate each member of an array value.
#
# @example validate format of all strings in an array
#
# argument :handles, [String],
# validates: { all: { format: { with: /\A[a-z0-9_]+\Z/... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/visibility/visit.rb | Ruby | mit | 5,430 | master | 7,499 | # frozen_string_literal: true
module GraphQL
class Schema
class Visibility
class Visit
def initialize(schema, &visit_block)
@schema = schema
@late_bound_types = nil
@unvisited_types = nil
# These accumulate between calls to prevent re-visiting the same types
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/visibility/profile.rb | Ruby | mit | 5,430 | master | 15,891 | # frozen_string_literal: true
module GraphQL
class Schema
class Visibility
# This class filters the types, fields, arguments, enum values, and directives in a schema
# based on the given `context`.
#
# It's like {Warden}, but has some differences:
#
# - It doesn't use {Schema}... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/visibility/migration.rb | Ruby | mit | 5,430 | master | 7,472 | # frozen_string_literal: true
module GraphQL
class Schema
class Visibility
# You can use this to see how {GraphQL::Schema::Warden} and {GraphQL::Schema::Visibility::Profile}
# handle `.visible?` differently in your schema.
#
# It runs the same method on both implementations and raises an e... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/resolver/has_payload_type.rb | Ruby | mit | 5,430 | master | 3,830 | # frozen_string_literal: true
module GraphQL
class Schema
class Resolver
# Adds `field(...)` helper to resolvers so that they can
# generate payload types.
#
# Or, an already-defined one can be attached with `payload_type(...)`.
module HasPayloadType
# Call this method to ge... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_interfaces.rb | Ruby | mit | 5,430 | master | 5,411 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasInterfaces
def implements(*new_interfaces, **options)
new_memberships = []
new_interfaces.each do |int|
if int.is_a?(Module)
unless int.include?(GraphQL::Schema::Interface)... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_unresolved_type_error.rb | Ruby | mit | 5,430 | master | 581 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
# Set up a type-specific error to make debugging & bug tracker integration better
module HasUnresolvedTypeError
private
def add_unresolved_type_error(child_class)
if child_class.name # Don't set this for ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_directives.rb | Ruby | mit | 5,430 | master | 4,093 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasDirectives
def self.extended(child_cls)
super
child_cls.module_exec { self.own_directives = nil }
end
def inherited(child_cls)
super
child_cls.own_directives = n... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_ast_node.rb | Ruby | mit | 5,430 | master | 721 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasAstNode
def self.extended(child_cls)
super
child_cls.ast_node = nil
end
def inherited(child_cls)
super
child_cls.ast_node = nil
end
# If this sch... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/type_system_helpers.rb | Ruby | mit | 5,430 | master | 1,668 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module TypeSystemHelpers
def initialize(...)
super
@to_non_null_type ||= nil
@to_list_type ||= nil
end
# @return [Schema::NonNull] Make a non-null-type representation of this type
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_deprecation_reason.rb | Ruby | mit | 5,430 | master | 1,181 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasDeprecationReason
# @return [String, nil] Explains why this member was deprecated (if present, this will be marked deprecated in introspection)
attr_reader :deprecation_reason
# Set the deprecation rea... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_dataloader.rb | Ruby | mit | 5,430 | master | 4,881 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
# @api public
# Shared methods for working with {Dataloader} inside GraphQL runtime objects.
module HasDataloader
# @return [GraphQL::Dataloader] The dataloader for the currently-running query
def dataloader
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_authorization.rb | Ruby | mit | 5,430 | master | 865 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasAuthorization
def self.included(child_class)
child_class.include(InstanceConfigured)
end
def self.extended(child_class)
child_class.extend(ClassConfigured)
child_class.clas... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_validators.rb | Ruby | mit | 5,430 | master | 1,571 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasValidators
include GraphQL::EmptyObjects
# Build {GraphQL::Schema::Validator}s based on the given configuration
# and use them for this schema member
# @param validation_config [Hash{Symbol => H... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/validates_input.rb | Ruby | mit | 5,430 | master | 842 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module ValidatesInput
def valid_input?(val, ctx)
validate_input(val, ctx).valid?
end
def validate_input(val, ctx, max_errors: nil)
if val.nil?
Query::InputValidationResult::VALID
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_path.rb | Ruby | mit | 5,430 | master | 621 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasPath
# @return [String] A description of this member's place in the GraphQL schema
def path
path_str = if self.respond_to?(:graphql_name)
self.graphql_name
elsif self.class.respo... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/base_dsl_methods.rb | Ruby | mit | 5,430 | master | 4,078 | # frozen_string_literal: true
require "graphql/schema/find_inherited_value"
module GraphQL
class Schema
class Member
# DSL methods shared by lots of things in the GraphQL Schema.
# @api private
# @see Classes that extend this, eg {GraphQL::Schema::Object}
module BaseDSLMethods
in... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/graphql_type_names.rb | Ruby | mit | 5,430 | master | 473 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
# These constants are interpreted as GraphQL types when defining fields or arguments
#
# @example
# field :is_draft, Boolean, null: false
# field :id, ID, null: false
# field :score, Int, null: false
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/build_type.rb | Ruby | mit | 5,430 | master | 6,522 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
# @api private
module BuildType
LIST_TYPE_ERROR = "Use an array of [T] or [T, null: true] for list types; other arrays are not supported"
module_function
# @param type_expr [String, Class, GraphQL::BaseType... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/scoped.rb | Ruby | mit | 5,430 | master | 1,153 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module Scoped
# This is called when a field has `scope: true`.
# The field's return type class receives this call.
#
# By default, it's a no-op. Override it to scope your objects.
#
# @par... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_fields.rb | Ruby | mit | 5,430 | master | 18,203 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
# Shared code for Objects, Interfaces, Mutations, Subscriptions
module HasFields
include EmptyObjects
# Add a field to this object or interface with the given definition
# @param name_positional [Symbol] Th... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/relay_shortcuts.rb | Ruby | mit | 5,430 | master | 2,930 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module RelayShortcuts
def edge_type_class(new_edge_type_class = nil)
if new_edge_type_class
initialize_relay_metadata
@edge_type_class = new_edge_type_class
else
# Don't ca... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/member/has_arguments.rb | Ruby | mit | 5,430 | master | 19,266 | # frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasArguments
def self.included(cls)
cls.extend(ArgumentClassAccessor)
cls.include(ArgumentObjectLoader)
end
def self.extended(cls)
cls.extend(ArgumentClassAccessor)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/specified_by.rb | Ruby | mit | 5,430 | master | 451 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
class SpecifiedBy < GraphQL::Schema::Directive
description "Exposes a URL that specifies the behavior of this scalar."
locations(GraphQL::Schema::Directive::SCALAR)
default_directive t... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/flagged.rb | Ruby | mit | 5,430 | master | 2,370 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
# This is _similar_ to {Directive::Feature}, except it's prescribed by the server, not the client.
#
# In this case, the server hides types and fields _entirely_, unless the current context has ce... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/one_of.rb | Ruby | mit | 5,430 | master | 557 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
class OneOf < GraphQL::Schema::Directive
description "Requires that exactly one field must be supplied and that field must not be `null`."
locations(GraphQL::Schema::Directive::INPUT_OBJECT)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/feature.rb | Ruby | mit | 5,430 | master | 2,822 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
# An example directive to show how you might interact with the runtime.
#
# This directive might be used along with a server-side feature flag system like Flipper.
#
# With that system... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/deprecated.rb | Ruby | mit | 5,430 | master | 878 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
class Deprecated < GraphQL::Schema::Directive
description "Marks an element of a GraphQL schema as no longer supported."
locations(GraphQL::Schema::Directive::FIELD_DEFINITION, GraphQL::Schema... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/skip.rb | Ruby | mit | 5,430 | master | 647 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
class Skip < Schema::Directive
description "Directs the executor to skip this field or fragment when the `if` argument is true."
locations(
GraphQL::Schema::Directive::FIELD,
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/transform.rb | Ruby | mit | 5,430 | master | 1,943 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
# An example directive to show how you might interact with the runtime.
#
# This directive takes the return value of the tagged part of the query,
# and if the named transform is whitelisted... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/directive/include.rb | Ruby | mit | 5,430 | master | 669 | # frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
class Include < GraphQL::Schema::Directive
description "Directs the executor to include this field or fragment only when the `if` argument is true."
locations(
GraphQL::Schema::Dire... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/field/scope_extension.rb | Ruby | mit | 5,430 | master | 1,099 | # frozen_string_literal: true
module GraphQL
class Schema
class Field
class ScopeExtension < GraphQL::Schema::FieldExtension
def after_resolve(object:, arguments:, context:, value:, memo:)
if object.is_a?(GraphQL::Schema::Object)
if value.nil?
value
e... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema/field/connection_extension.rb | Ruby | mit | 5,430 | master | 1,383 | # frozen_string_literal: true
module GraphQL
class Schema
class Field
class ConnectionExtension < GraphQL::Schema::FieldExtension
def apply
field.argument :after, "String", "Returns the elements in the list that come after the specified cursor.", required: false
field.argument :... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/relay/range_add.rb | Ruby | mit | 5,430 | master | 2,098 | # frozen_string_literal: true
module GraphQL
module Relay
# This provides some isolation from `GraphQL::Relay` internals.
#
# Given a list of items and a new item, it will provide a connection and an edge.
#
# The connection doesn't receive outside arguments, so the list of items
# should be o... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/static_visitor.rb | Ruby | mit | 5,430 | master | 6,191 | # frozen_string_literal: true
module GraphQL
module Language
# Like `GraphQL::Language::Visitor` except it doesn't support
# making changes to the document -- only visiting it as-is.
class StaticVisitor
def initialize(document)
@document = document
end
# Visit `document` and all... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/block_string.rb | Ruby | mit | 5,430 | master | 3,157 | # frozen_string_literal: true
module GraphQL
module Language
module BlockString
# Remove leading and trailing whitespace from a block string.
# See "Block Strings" in https://github.com/facebook/graphql/blob/master/spec/Section%202%20--%20Language.md
def self.trim_whitespace(str)
# Early... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/lexer.rb | Ruby | mit | 5,430 | master | 12,238 | # frozen_string_literal: true
module GraphQL
module Language
class Lexer
def initialize(graphql_str, filename: nil, max_tokens: nil)
if !(graphql_str.encoding == Encoding::UTF_8 || graphql_str.ascii_only?)
graphql_str = graphql_str.dup.force_encoding(Encoding::UTF_8)
end
@... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/sanitized_printer.rb | Ruby | mit | 5,430 | master | 7,017 | # frozen_string_literal: true
module GraphQL
module Language
# A custom printer used to print sanitized queries. It inlines provided variables
# within the query for facilitate logging and analysis of queries.
#
# The printer returns `nil` if the query is invalid.
#
# Since the GraphQL Ruby AS... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/generation.rb | Ruby | mit | 5,430 | master | 934 | # frozen_string_literal: true
module GraphQL
module Language
# Exposes {.generate}, which turns AST nodes back into query strings.
module Generation
extend self
# Turn an AST node back into a string.
#
# @example Turning a document into a query
# document = GraphQL.parse(quer... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/printer.rb | Ruby | mit | 5,430 | master | 18,569 | # frozen_string_literal: true
module GraphQL
module Language
class Printer
OMISSION = "... (truncated)"
class TruncatableBuffer
class TruncateSizeReached < StandardError; end
DEFAULT_INIT_CAPACITY = 500
def initialize(truncate_size: nil)
@out = String.new(capacity:... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/definition_slice.rb | Ruby | mit | 5,430 | master | 1,176 | # frozen_string_literal: true
module GraphQL
module Language
module DefinitionSlice
extend self
def slice(document, name)
definitions = {}
document.definitions.each { |d| definitions[d.name] = d }
names = Set.new
DependencyVisitor.find_definition_dependencies(definitio... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/comment.rb | Ruby | mit | 5,430 | master | 391 | # frozen_string_literal: true
module GraphQL
module Language
module Comment
def self.print(str, indent: '')
lines = str.split("\n").map do |line|
comment_str = "".dup
comment_str << indent
comment_str << "# "
comment_str << line
comment_str.rstrip
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/visitor.rb | Ruby | mit | 5,430 | master | 11,334 | # frozen_string_literal: true
module GraphQL
module Language
# Depth-first traversal through the tree, calling hooks at each stop.
#
# @example Create a visitor counting certain field names
# class NameCounter < GraphQL::Language::Visitor
# def initialize(document, field_name)
# su... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/cache.rb | Ruby | mit | 5,430 | master | 1,666 | # frozen_string_literal: true
require 'graphql/version'
require 'digest/sha2'
module GraphQL
module Language
# This cache is used by {GraphQL::Language::Parser.parse_file} when it's enabled.
#
# With Rails, parser caching may enabled by setting `config.graphql.parser_cache = true` in your Rails applicat... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/document_from_schema_definition.rb | Ruby | mit | 5,430 | master | 14,248 | # frozen_string_literal: true
module GraphQL
module Language
# @api private
#
# {GraphQL::Language::DocumentFromSchemaDefinition} is used to convert a {GraphQL::Schema} object
# To a {GraphQL::Language::Document} AST node.
#
# @param context [Hash]
# @param only [<#call(member, ctx)>]
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/nodes.rb | Ruby | mit | 5,430 | master | 27,514 | # frozen_string_literal: true
module GraphQL
module Language
module Nodes
NONE = GraphQL::EmptyObjects::EMPTY_ARRAY
# {AbstractNode} is the base class for all nodes in a GraphQL AST.
#
# It provides some APIs for working with ASTs:
# - `children` returns all AST nodes attached to thi... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language/parser.rb | Ruby | mit | 5,430 | master | 27,301 | # frozen_string_literal: true
require "strscan"
require "graphql/language/nodes"
require "graphql/tracing/null_trace"
module GraphQL
module Language
class Parser
include GraphQL::Language::Nodes
include EmptyObjects
class << self
attr_accessor :cache
def parse(graphql_str, fi... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/fingerprint.rb | Ruby | mit | 5,430 | master | 736 | # frozen_string_literal: true
require 'digest/sha2'
module GraphQL
class Query
# @api private
# @see Query#query_fingerprint
# @see Query#variables_fingerprint
# @see Query#fingerprint
module Fingerprint
# Make an obfuscated hash of the given string (either a query string or variables JSON... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/result.rb | Ruby | mit | 5,430 | master | 1,651 | # frozen_string_literal: true
module GraphQL
class Query
# A result from {Schema#execute}.
# It provides the requested data and
# access to the {Query} and {Query::Context}.
class Result
extend Forwardable
def initialize(query:, values:)
@query = query
@to_h = values
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/input_validation_result.rb | Ruby | mit | 5,430 | master | 1,425 | # frozen_string_literal: true
module GraphQL
class Query
class InputValidationResult
attr_accessor :problems
def self.from_problem(explanation, path = nil, extensions: nil, message: nil)
result = self.new
result.add_problem(explanation, path, extensions: extensions, message: message)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/variable_validation_error.rb | Ruby | mit | 5,430 | master | 1,368 | # frozen_string_literal: true
module GraphQL
class Query
class VariableValidationError < GraphQL::ExecutionError
attr_accessor :value, :validation_result
def initialize(variable_ast, type, value, validation_result, msg: nil)
@value = value
@validation_result = validation_result
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/context.rb | Ruby | mit | 5,430 | master | 8,565 | # frozen_string_literal: true
module GraphQL
class Query
# Expose some query-specific info to field resolve functions.
# It delegates `[]` to the hash that's passed to `GraphQL::Query#initialize`.
class Context
class ExecutionErrors
def initialize(ctx)
@context = ctx
end
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/validation_pipeline.rb | Ruby | mit | 5,430 | master | 3,849 | # frozen_string_literal: true
module GraphQL
class Query
# Contain the validation pipeline and expose the results.
#
# 0. Checks in {Query#initialize}:
# - Rescue a ParseError, halt if there is one
# - Check for selected operation, halt if not found
# 1. Validate the AST, halt if errors
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/partial.rb | Ruby | mit | 5,430 | master | 5,700 | # frozen_string_literal: true
module GraphQL
class Query
# This class is _like_ a {GraphQL::Query}, except it can run on an arbitrary path within a query string.
#
# It depends on a "parent" {Query}.
#
# During execution, it calls query-related tracing hooks but passes itself as `query:`.
#
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/null_context.rb | Ruby | mit | 5,430 | master | 977 | # frozen_string_literal: true
require "graphql/query/context"
module GraphQL
class Query
# This object can be `ctx` in places where there is no query
class NullContext < Context
def self.instance
@instance ||= self.new
end
def self.instance=(new_inst)
@instance = new_inst
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/variables.rb | Ruby | mit | 5,430 | master | 3,811 | # frozen_string_literal: true
module GraphQL
class Query
# Read-only access to query variables, applying default values if needed.
class Variables
extend Forwardable
# @return [Array<GraphQL::Query::VariableValidationError>] Any errors encountered when parsing the provided variables and literal ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query/context/scoped_context.rb | Ruby | mit | 5,430 | master | 2,549 | # frozen_string_literal: true
module GraphQL
class Query
class Context
class ScopedContext
def initialize(query_context)
@query_context = query_context
@scoped_contexts = nil
@all_keys = nil
end
def merged_context
if @scoped_contexts.nil?
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/field_usage.rb | Ruby | mit | 5,430 | master | 2,978 | # frozen_string_literal: true
module GraphQL
module Analysis
class FieldUsage < Analyzer
def initialize(query)
super
@used_fields = Set.new
@used_deprecated_fields = Set.new
@used_deprecated_arguments = Set.new
@used_deprecated_enum_values = Set.new
end
d... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/query_depth.rb | Ruby | mit | 5,430 | master | 1,613 | # frozen_string_literal: true
module GraphQL
module Analysis
# A query reducer for measuring the depth of a given query.
#
# See https://graphql-ruby.org/queries/ast_analysis.html for more examples.
#
# @example Logging the depth of a query
# class LogQueryDepth < GraphQL::Analysis::QueryDep... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/visitor.rb | Ruby | mit | 5,430 | master | 8,875 | # frozen_string_literal: true
module GraphQL
module Analysis
# Depth first traversal through a query AST, calling AST analyzers
# along the way.
#
# The visitor is a special case of GraphQL::Language::StaticVisitor, visiting
# only the selected operation, providing helpers for common use cases suc... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/max_query_complexity.rb | Ruby | mit | 5,430 | master | 612 | # frozen_string_literal: true
module GraphQL
module Analysis
# Used under the hood to implement complexity validation,
# see {Schema#max_complexity} and {Query#max_complexity}
class MaxQueryComplexity < QueryComplexity
def result
return if subject.max_complexity.nil?
total_complexit... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/query_complexity.rb | Ruby | mit | 5,430 | master | 11,834 | # frozen_string_literal: true
module GraphQL
module Analysis
# Calculate the complexity of a query, using {Field#complexity} values.
class QueryComplexity < Analyzer
# State for the query complexity calculation:
# - `complexities_on_type` holds complexity scores for each type
def initialize(... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/analyzer.rb | Ruby | mit | 5,430 | master | 2,993 | # frozen_string_literal: true
module GraphQL
module Analysis
# Query analyzer for query ASTs. Query analyzers respond to visitor style methods
# but are prefixed by `enter` and `leave`.
#
# When an analyzer is initialized with a Multiplex, you can always get the current query from
# `visitor.query... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis/max_query_depth.rb | Ruby | mit | 5,430 | master | 507 | # frozen_string_literal: true
module GraphQL
module Analysis
class MaxQueryDepth < QueryDepth
def result
configured_max_depth = if query
query.max_depth
else
multiplex.schema.max_depth
end
if configured_max_depth && @max_depth > configured_max_depth
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/subscriptions/broadcast_analyzer.rb | Ruby | mit | 5,430 | master | 3,579 | # frozen_string_literal: true
module GraphQL
class Subscriptions
# Detect whether the current operation:
# - Is a subscription operation
# - Is completely broadcastable
#
# Assign the result to `context.namespace(:subscriptions)[:subscription_broadcastable]`
# @api private
# @see Subscrip... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/subscriptions/event.rb | Ruby | mit | 5,430 | master | 6,553 | # frozen_string_literal: true
module GraphQL
class Subscriptions
# This thing can be:
# - Subscribed to by `subscription { ... }`
# - Triggered by `MySchema.subscriber.trigger(name, arguments, obj)`
#
class Event
# @return [String] Corresponds to the Subscription root field name
attr_r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.