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 | spec/dummy/test/channels/graphql_channel_test.rb | Ruby | mit | 5,430 | master | 4,819 | # frozen_string_literal: true
require "test_helper"
class GraphqlChannelTest < ActionCable::Channel::TestCase
module RealChannelStub
def confirmed?
subscription_confirmation_sent?
end
def real_streams
streams
end
end
def assert_has_real_stream(stream_name)
assert subscription.re... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | graphql-c_parser/Rakefile | Ruby | mit | 5,430 | master | 280 | # frozen_string_literal: true
require "bundler/gem_helper"
# use a custom tag to avoid conflicting with GraphQL-Ruby tags in the same git repo
class CustomGemHelper < Bundler::GemHelper
def version_tag
"graphql-c_parser-v#{version}"
end
end
CustomGemHelper.install_tasks |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | graphql-c_parser/graphql-c_parser.gemspec | Ruby | mit | 5,430 | master | 1,095 | # frozen_string_literal: true
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
require "graphql/c_parser/version"
require "date"
Gem::Specification.new do |s|
s.name = "graphql-c_parser"
s.version = GraphQL::CParser::VERSION
s.date = Date.today.to_s
s.summary = "A parser for GraphQL, ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | graphql-c_parser/lib/graphql/c_parser.rb | Ruby | mit | 5,430 | master | 5,216 | # frozen_string_literal: true
require "graphql"
require "graphql/c_parser/version"
require "graphql/graphql_c_parser_ext"
module GraphQL
module CParser
def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace, max_tokens: nil)
Parser.parse(query_str, filename: filename, trace: trace, ma... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | cop/development/context_is_passed_cop.rb | Ruby | mit | 5,430 | master | 1,568 | # frozen_string_literal: true
require 'rubocop'
module Cop
module Development
class ContextIsPassedCop < RuboCop::Cop::Base
MSG = <<-MSG
This method also accepts `context` as an argument. Pass it so that the returned value will reflect the current query, or use another method that isn't context-dependent.
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | cop/development/no_focus_cop.rb | Ruby | mit | 5,430 | master | 483 | # frozen_string_literal: true
require 'rubocop'
module Cop
module Development
# Make sure no tests are focused, from https://github.com/rubocop-hq/rubocop/issues/3773#issuecomment-420662102
class NoFocusCop < RuboCop::Cop::Base
MSG = 'Remove `focus` from tests.'
def_node_matcher :focused?, <<-MA... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | cop/development/no_eval_cop.rb | Ruby | mit | 5,430 | master | 632 | # frozen_string_literal: true
require 'rubocop'
module Cop
module Development
class NoEvalCop < RuboCop::Cop::Base
MSG_TEMPLATE = "Don't use `%{eval_method_name}` which accepts strings and may result evaluating unexpected code. Use `%{exec_method_name}` instead, and pass a block."
def on_send(node)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | cop/development/trace_methods_cop.rb | Ruby | mit | 5,430 | master | 3,282 | # frozen_string_literal: true
require 'rubocop'
module Cop
module Development
class TraceMethodsCop < RuboCop::Cop::Base
extend RuboCop::Cop::AutoCorrector
TRACE_HOOKS = [
:analyze_multiplex,
:analyze_query,
:authorized,
:authorized_lazy,
:begin_analyze_multip... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | cop/development/none_without_block_cop.rb | Ruby | mit | 5,430 | master | 1,530 | # frozen_string_literal: true
require 'rubocop'
module Cop
module Development
# A custom Rubocop rule to catch uses of `.none?` without a block.
#
# @see https://github.com/rmosolgo/graphql-ruby/pull/2090
class NoneWithoutBlockCop < RuboCop::Cop::Base
MSG = <<-MD
Instead of `.none?` or `.any?` ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql.rb | Ruby | mit | 5,430 | master | 5,071 | # frozen_string_literal: true
require "delegate"
require "json"
require "set"
require "singleton"
require "forwardable"
require "fiber/storage" if RUBY_VERSION < "3.2.0"
require "graphql/autoload"
module GraphQL
extend Autoload
# Load all `autoload`-configured classes, and also eager-load dependents who have auto... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/invalid_name_error.rb | Ruby | mit | 5,430 | master | 311 | # frozen_string_literal: true
module GraphQL
class InvalidNameError < GraphQL::Error
attr_reader :name, :valid_regex
def initialize(name, valid_regex)
@name = name
@valid_regex = valid_regex
super("Names must match #{@valid_regex.inspect} but '#{@name}' does not")
end
end
end |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/execution.rb | Ruby | mit | 5,430 | master | 567 | # frozen_string_literal: true
require "graphql/execution/directive_checks"
require "graphql/execution/next"
require "graphql/execution/interpreter"
require "graphql/execution/lazy"
require "graphql/execution/lookahead"
require "graphql/execution/multiplex"
require "graphql/execution/errors"
module GraphQL
module Exe... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/invalid_null_error.rb | Ruby | mit | 5,430 | master | 1,955 | # frozen_string_literal: true
module GraphQL
# Raised automatically when a field's resolve function returns `nil`
# for a non-null field.
class InvalidNullError < GraphQL::RuntimeError
# @return [GraphQL::BaseType] The owner of {#field}
attr_reader :parent_type
# @return [GraphQL::Field] The field wh... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/tracing.rb | Ruby | mit | 5,430 | master | 3,178 | # frozen_string_literal: true
module GraphQL
module Tracing
autoload :Trace, "graphql/tracing/trace"
autoload :CallLegacyTracers, "graphql/tracing/call_legacy_tracers"
autoload :LegacyTrace, "graphql/tracing/legacy_trace"
autoload :LegacyHooksTrace, "graphql/tracing/legacy_hooks_trace"
autoload ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/language.rb | Ruby | mit | 5,430 | master | 3,686 | # frozen_string_literal: true
require "graphql/language/block_string"
require "graphql/language/comment"
require "graphql/language/printer"
require "graphql/language/sanitized_printer"
require "graphql/language/document_from_schema_definition"
require "graphql/language/generation"
require "graphql/language/lexer"
requi... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/unauthorized_enum_value_error.rb | Ruby | mit | 5,430 | master | 470 | # frozen_string_literal: true
module GraphQL
class UnauthorizedEnumValueError < GraphQL::UnauthorizedError
# @return [GraphQL::Schema::EnumValue] The value whose `#authorized?` check returned false
attr_accessor :enum_value
def initialize(type:, context:, enum_value:)
@enum_value = enum_value
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/railtie.rb | Ruby | mit | 5,430 | master | 613 | # frozen_string_literal: true
module GraphQL
# Support {GraphQL::Parser::Cache} and {GraphQL.eager_load!}
#
# @example Enable the parser cache with default directory
#
# config.graphql.parser_cache = true
#
class Railtie < Rails::Railtie
config.graphql = ActiveSupport::OrderedOptions.new
config... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/dataloader.rb | Ruby | mit | 5,430 | master | 12,787 | # frozen_string_literal: true
require "graphql/dataloader/null_dataloader"
require "graphql/dataloader/request"
require "graphql/dataloader/request_all"
require "graphql/dataloader/source"
require "graphql/dataloader/active_record_association_source"
require "graphql/dataloader/active_record_source"
module GraphQL
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/integer_encoding_error.rb | Ruby | mit | 5,430 | master | 1,165 | # frozen_string_literal: true
module GraphQL
# This error is raised when `Types::Int` is asked to return a value outside of 32-bit integer range.
#
# For values outside that range, consider:
#
# - `ID` for database primary keys or other identifiers
# - `GraphQL::Types::BigInt` for really big integer values
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/types.rb | Ruby | mit | 5,430 | master | 621 | # frozen_string_literal: true
module GraphQL
module Types
extend Autoload
autoload :Boolean, "graphql/types/boolean"
autoload :BigInt, "graphql/types/big_int"
autoload :Float, "graphql/types/float"
autoload :ID, "graphql/types/id"
autoload :Int, "graphql/types/int"
autoload :JSON, "graph... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/analysis.rb | Ruby | mit | 5,430 | master | 3,300 | # frozen_string_literal: true
require "graphql/analysis/visitor"
require "graphql/analysis/analyzer"
require "graphql/analysis/field_usage"
require "graphql/analysis/query_complexity"
require "graphql/analysis/max_query_complexity"
require "graphql/analysis/query_depth"
require "graphql/analysis/max_query_depth"
module... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/autoload.rb | Ruby | mit | 5,430 | master | 1,098 | # frozen_string_literal: true
module GraphQL
# @see GraphQL::Railtie for automatic Rails integration
module Autoload
# Register a constant named `const_name` to be loaded from `path`.
# This is like `Kernel#autoload` but it tracks the constants so they can be eager-loaded with {#eager_load!}
# @param c... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/integer_decoding_error.rb | Ruby | mit | 5,430 | master | 576 | # frozen_string_literal: true
module GraphQL
# This error is raised when `Types::Int` is given an input value outside of 32-bit integer range.
#
# For really big integer values, consider `GraphQL::Types::BigInt`
#
# @see GraphQL::Types::Int which raises this error
class IntegerDecodingError < GraphQL::Runti... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/pagination.rb | Ruby | mit | 5,430 | master | 292 | # frozen_string_literal: true
require "graphql/pagination/array_connection"
require "graphql/pagination/active_record_relation_connection"
require "graphql/pagination/connections"
require "graphql/pagination/mongoid_relation_connection"
require "graphql/pagination/sequel_dataset_connection" |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/schema.rb | Ruby | mit | 5,430 | master | 86,596 | # frozen_string_literal: true
require "logger"
require "graphql/schema/addition"
require "graphql/schema/always_visible"
require "graphql/schema/base_64_encoder"
require "graphql/schema/find_inherited_value"
require "graphql/schema/finder"
require "graphql/schema/introspection_system"
require "graphql/schema/late_bound... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/current.rb | Ruby | mit | 5,430 | master | 1,849 | # frozen_string_literal: true
module GraphQL
# This module exposes Fiber-level runtime information.
#
# It won't work across unrelated fibers, although it will work in child Fibers.
#
# @example Setting Up ActiveRecord::QueryLogs
#
# config.active_record.query_log_tags = [
# :namespaced_controlle... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/dashboard.rb | Ruby | mit | 5,430 | master | 4,097 | # frozen_string_literal: true
require 'rails/engine'
require 'action_controller'
module Graphql
# `GraphQL::Dashboard` is a `Rails::Engine`-based dashboard for viewing metadata about your GraphQL schema.
#
# Pass the class name of your schema when mounting it.
# @see GraphQL::Tracing::DetailedTrace DetailedTrac... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/name_validator.rb | Ruby | mit | 5,430 | master | 319 | # frozen_string_literal: true
module GraphQL
class NameValidator
VALID_NAME_REGEX = /^[_a-zA-Z][_a-zA-Z0-9]*$/
def self.validate!(name)
name = name.is_a?(String) ? name : name.to_s
raise GraphQL::InvalidNameError.new(name, VALID_NAME_REGEX) unless name.match?(VALID_NAME_REGEX)
end
end
end |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/unauthorized_error.rb | Ruby | mit | 5,430 | master | 1,282 | # frozen_string_literal: true
module GraphQL
# When an `authorized?` hook returns false, this error is used to communicate the failure.
# It's passed to {Schema.unauthorized_object}.
#
# Alternatively, custom code in `authorized?` may raise this error. It will be routed the same way.
class UnauthorizedError <... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/rubocop.rb | Ruby | mit | 5,430 | master | 247 | # frozen_string_literal: true
require "graphql/rubocop/graphql/default_null_true"
require "graphql/rubocop/graphql/default_required_true"
require "graphql/rubocop/graphql/field_type_in_block"
require "graphql/rubocop/graphql/root_types_in_block" |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/unauthorized_field_error.rb | Ruby | mit | 5,430 | master | 802 | # frozen_string_literal: true
module GraphQL
class UnauthorizedFieldError < GraphQL::UnauthorizedError
# @return [Field] the field that failed the authorization check
attr_accessor :field
def initialize(message = nil, object: nil, type: nil, context: nil, field: nil)
if message.nil? && [field, type... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/execution_error.rb | Ruby | mit | 5,430 | master | 1,882 | # frozen_string_literal: true
module GraphQL
# If a field's resolve function returns a {ExecutionError},
# the error will be inserted into the response's `"errors"` key
# and the field will resolve to `nil`.
class ExecutionError < GraphQL::RuntimeError
# @return [GraphQL::Language::Nodes::Field] the field w... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/introspection.rb | Ruby | mit | 5,430 | master | 2,804 | # frozen_string_literal: true
module GraphQL
module Introspection
def self.query(include_deprecated_args: false, include_schema_description: false, include_is_repeatable: false, include_specified_by_url: false, include_is_one_of: false)
# The introspection query to end all introspection queries, copied from... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/parse_error.rb | Ruby | mit | 5,430 | master | 509 | # frozen_string_literal: true
module GraphQL
class ParseError < GraphQL::Error
attr_reader :line, :col, :query
def initialize(message, line, col, query, filename: nil)
if filename
message += " (#{filename})"
end
super(message)
@line = line
@col = col
@query = query... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/type_kinds.rb | Ruby | mit | 5,430 | master | 3,098 | # frozen_string_literal: true
module GraphQL
# Type kinds are the basic categories which a type may belong to (`Object`, `Scalar`, `Union`...)
module TypeKinds
# These objects are singletons, eg `GraphQL::TypeKinds::UNION`, `GraphQL::TypeKinds::SCALAR`.
class TypeKind
attr_reader :name, :description
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/load_application_object_failed_error.rb | Ruby | mit | 5,430 | master | 1,002 | # frozen_string_literal: true
module GraphQL
# Raised when a argument is configured with `loads:` and the client provides an `ID`,
# but no object is loaded for that ID.
#
# @see GraphQL::Schema::Member::HasArguments::ArgumentObjectLoader#load_application_object_failed, A hook which you can override in resolve... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/rake_task.rb | Ruby | mit | 5,430 | master | 5,030 | # frozen_string_literal: true
require "fileutils"
require "rake"
require "graphql/rake_task/validate"
module GraphQL
# A rake task for dumping a schema as IDL or JSON.
#
# By default, schemas are looked up by name as constants using `schema_name:`.
# You can provide a `load_schema` function to return your sche... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/subscriptions.rb | Ruby | mit | 5,430 | master | 12,931 | # frozen_string_literal: true
require "securerandom"
require "graphql/subscriptions/broadcast_analyzer"
require "graphql/subscriptions/event"
require "graphql/subscriptions/serialize"
require "graphql/subscriptions/action_cable_subscriptions"
require "graphql/subscriptions/default_subscription_resolve_extension"
modul... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/date_encoding_error.rb | Ruby | mit | 5,430 | master | 529 | # frozen_string_literal: true
module GraphQL
# This error is raised when `Types::ISO8601Date` is asked to return a value
# that cannot be parsed to a Ruby Date.
#
# @see GraphQL::Types::ISO8601Date which raises this error
class DateEncodingError < GraphQL::RuntimeTypeError
# The value which couldn't be en... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/backtrace.rb | Ruby | mit | 5,430 | master | 921 | # frozen_string_literal: true
require "graphql/backtrace/table"
require "graphql/backtrace/traced_error"
module GraphQL
# Wrap unhandled errors with {TracedError}.
#
# {TracedError} provides a GraphQL backtrace with arguments and return values.
# The underlying error is available as {TracedError#cause}.
#
#... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/duration_encoding_error.rb | Ruby | mit | 5,430 | master | 592 | # frozen_string_literal: true
module GraphQL
# This error is raised when `Types::ISO8601Duration` is asked to return a value
# that cannot be parsed as an ISO8601-formatted duration by ActiveSupport::Duration.
#
# @see GraphQL::Types::ISO8601Duration which raises this error
class DurationEncodingError < Graph... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/string_encoding_error.rb | Ruby | mit | 5,430 | master | 590 | # frozen_string_literal: true
module GraphQL
class StringEncodingError < GraphQL::RuntimeTypeError
attr_reader :string, :field, :path
def initialize(str, context:)
@string = str
@field = context[:current_field]
@path = context[:current_path]
message = "String #{str.inspect} was encoded... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation.rb | Ruby | mit | 5,430 | master | 632 | # frozen_string_literal: true
require "graphql/static_validation/error"
require "graphql/static_validation/definition_dependencies"
require "graphql/static_validation/validator"
require "graphql/static_validation/validation_context"
require "graphql/static_validation/validation_timeout_error"
require "graphql/static_va... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/unresolved_type_error.rb | Ruby | mit | 5,430 | master | 1,640 | # frozen_string_literal: true
module GraphQL
# Error raised when the value provided for a field
# can't be resolved to one of the possible types for the field.
class UnresolvedTypeError < GraphQL::RuntimeTypeError
# @return [Object] The runtime value which couldn't be successfully resolved with `resolve_type`... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/query.rb | Ruby | mit | 5,430 | master | 18,562 | # frozen_string_literal: true
module GraphQL
# A combination of query string and {Schema} instance which can be reduced to a {#result}.
class Query
extend Autoload
include Tracing::Traceable
extend Forwardable
autoload :Context, "graphql/query/context"
autoload :Fingerprint, "graphql/query/fin... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/dig.rb | Ruby | mit | 5,430 | master | 656 | # frozen_string_literal: true
module GraphQL
module Dig
# implemented using the old activesupport #dig instead of the ruby built-in
# so we can use some of the magic in Schema::InputObject and Interpreter::Arguments
# to handle stringified/symbolized keys.
#
# @param own_key [String, Symbol] A key... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/rake_task/validate.rb | Ruby | mit | 5,430 | master | 2,466 | # frozen_string_literal: true
module GraphQL
class RakeTask
extend Rake::DSL
desc "Get the checksum of a graphql-pro version and compare it to published versions on GitHub and graphql-ruby.org"
task "graphql:pro:validate", [:gem_version] do |t, args|
version = args[:gem_version]
if version.n... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/backtrace/traced_error.rb | Ruby | mit | 5,430 | master | 1,749 | # frozen_string_literal: true
module GraphQL
class Backtrace
# When {Backtrace} is enabled, raised errors are wrapped with {TracedError}.
class TracedError < GraphQL::Error
# @return [Array<String>] Printable backtrace of GraphQL error context
attr_reader :graphql_backtrace
# @return [Graph... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/backtrace/table.rb | Ruby | mit | 5,430 | master | 5,512 | # frozen_string_literal: true
module GraphQL
class Backtrace
# A class for turning a context into a human-readable table or array
class Table
MIN_COL_WIDTH = 4
MAX_COL_WIDTH = 100
HEADERS = [
"Loc",
"Field",
"Object",
"Arguments",
"Result",
]
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/base_visitor.rb | Ruby | mit | 5,430 | master | 7,537 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class BaseVisitor < GraphQL::Language::StaticVisitor
def initialize(document, context)
@path = []
@path_depth = 0
@current_object_type = nil
@parent_object_type = nil
@current_field_definition = nil
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/validator.rb | Ruby | mit | 5,430 | master | 3,287 | # frozen_string_literal: true
require "timeout"
module GraphQL
module StaticValidation
# Initialized with a {GraphQL::Schema}, then it can validate {GraphQL::Language::Nodes::Documents}s based on that schema.
#
# By default, it's used by {GraphQL::Query}
#
# @example Validate a query
# vali... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/validation_timeout_error.rb | Ruby | mit | 5,430 | master | 514 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class ValidationTimeoutError < StaticValidation::Error
def initialize(message, path: nil, nodes: [])
super(message, path: path, nodes: nodes)
end
# A hash representation of this Message
def to_h
extension... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/all_rules.rb | Ruby | mit | 5,430 | master | 2,152 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# Default rules for {GraphQL::StaticValidation::Validator}
#
# Order is important here. Some validators skip later hooks.
# which stops the visit on that node. That way it doesn't try to find fields on types that
# don't exist, e... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/literal_validator.rb | Ruby | mit | 5,430 | master | 5,909 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# Test whether `ast_value` is a valid input for `type`
class LiteralValidator
def initialize(context:)
@context = context
@types = context.types
@invalid_response = GraphQL::Query::InputValidationResult.new(vali... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/interpreter_visitor.rb | Ruby | mit | 5,430 | master | 312 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class InterpreterVisitor < BaseVisitor
include(GraphQL::StaticValidation::DefinitionDependencies)
StaticValidation::ALL_RULES.reverse_each do |r|
include(r)
end
include(ContextMethods)
end
end
end |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/validation_context.rb | Ruby | mit | 5,430 | master | 2,274 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# The validation context gets passed to each validator.
#
# It exposes a {GraphQL::Language::Visitor} where validators may add hooks. ({Language::Visitor#visit} is called in {Validator#validate})
#
# It provides access to the sch... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/error.rb | Ruby | mit | 5,430 | master | 1,167 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# Generates GraphQL-compliant validation message.
class Error
# Convenience for validators
module ErrorHelper
# Error `error_message` is located at `node`
def error(error_message, nodes, context: nil, path: nil, e... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/definition_dependencies.rb | Ruby | mit | 5,430 | master | 8,143 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# Track fragment dependencies for operations
# and expose the fragment definitions which
# are used by a given operation
module DefinitionDependencies
attr_reader :dependencies
def initialize(*)
super
@de... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragments_are_used_error.rb | Ruby | mit | 5,430 | master | 638 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FragmentsAreUsedError < StaticValidation::Error
attr_reader :fragment_name
def initialize(message, path: nil, nodes: [], fragment:)
super(message, path: path, nodes: nodes)
@fragment_name = fragment
end
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variable_names_are_unique.rb | Ruby | mit | 5,430 | master | 716 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module VariableNamesAreUnique
def on_operation_definition(node, parent)
var_defns = node.variables
if !var_defns.empty?
vars_by_name = Hash.new { |h, k| h[k] = [] }
var_defns.each { |v| vars_by_name[v.na... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/unique_directives_per_location.rb | Ruby | mit | 5,430 | master | 2,165 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module UniqueDirectivesPerLocation
DIRECTIVE_NODE_HOOKS = [
:on_fragment_definition,
:on_fragment_spread,
:on_inline_fragment,
:on_operation_definition,
:on_scalar_type_definition,
:on_object... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragments_are_named.rb | Ruby | mit | 5,430 | master | 387 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FragmentsAreNamed
def on_fragment_definition(node, _parent)
if node.name.nil?
add_error(GraphQL::StaticValidation::FragmentsAreNamedError.new(
"Fragment definition has no name",
nodes: node
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb | Ruby | mit | 5,430 | master | 967 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class VariableUsagesAreAllowedError < StaticValidation::Error
attr_reader :type_name
attr_reader :variable_name
attr_reader :argument_name
attr_reader :error_message
def initialize(message, path: nil, nodes: [], ty... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb | Ruby | mit | 5,430 | master | 1,401 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class ArgumentLiteralsAreCompatibleError < StaticValidation::Error
attr_reader :type_name
attr_reader :argument_name
attr_reader :argument
attr_reader :value
def initialize(message, path: nil, nodes: [], type:, arg... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fields_will_merge_error.rb | Ruby | mit | 5,430 | master | 1,434 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FieldsWillMergeError < StaticValidation::Error
attr_reader :field_name
attr_reader :kind
def initialize(kind:, field_name:)
super(nil)
@field_name = field_name
@kind = kind
@conflicts = [... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variables_are_input_types.rb | Ruby | mit | 5,430 | master | 1,491 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module VariablesAreInputTypes
def on_variable_definition(node, parent)
type_name = get_type_name(node.type)
type = context.query.types.type(type_name)
if type.nil?
suggestion = if @schema.did_you_mean
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/required_arguments_are_present_error.rb | Ruby | mit | 5,430 | master | 831 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class RequiredArgumentsArePresentError < StaticValidation::Error
attr_reader :class_name
attr_reader :name
attr_reader :arguments
def initialize(message, path: nil, nodes: [], class_name:, name:, arguments:)
supe... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/unique_directives_per_location_error.rb | Ruby | mit | 5,430 | master | 664 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class UniqueDirectivesPerLocationError < StaticValidation::Error
attr_reader :directive_name
def initialize(message, path: nil, nodes: [], directive:)
super(message, path: path, nodes: nodes)
@directive_name = direct... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb | Ruby | mit | 5,430 | master | 604 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class InputObjectNamesAreUniqueError < StaticValidation::Error
attr_reader :name
def initialize(message, path: nil, nodes: [], name:)
super(message, path: path, nodes: nodes)
@name = name
end
# A hash re... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fields_are_defined_on_type.rb | Ruby | mit | 5,430 | master | 1,396 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FieldsAreDefinedOnType
def on_field(node, parent)
parent_type = @parent_object_type
field = context.query.types.field(parent_type, node.name)
if field.nil?
if parent_type.kind.union?
ad... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb | Ruby | mit | 5,430 | master | 2,452 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FragmentSpreadsArePossible
def initialize(*)
super
@spreads_to_validate = []
end
def on_inline_fragment(node, parent)
fragment_parent = @parent_object_type
fragment_child = @current_objec... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variable_names_are_unique_error.rb | Ruby | mit | 5,430 | master | 633 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class VariableNamesAreUniqueError < StaticValidation::Error
attr_reader :variable_name
def initialize(message, path: nil, nodes: [], name:)
super(message, path: path, nodes: nodes)
@variable_name = name
end
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragments_are_named_error.rb | Ruby | mit | 5,430 | master | 516 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FragmentsAreNamedError < StaticValidation::Error
def initialize(message, path: nil, nodes: [])
super(message, path: path, nodes: nodes)
end
# A hash representation of this Message
def to_h
extensio... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb | Ruby | mit | 5,430 | master | 1,100 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class VariableDefaultValuesAreCorrectlyTypedError < StaticValidation::Error
attr_reader :variable_name
attr_reader :type_name
attr_reader :violation
VIOLATIONS = {
:INVALID_TYPE => "defaultValueInvalidTyp... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/query_root_exists.rb | Ruby | mit | 5,430 | master | 489 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module QueryRootExists
def on_operation_definition(node, _parent)
if (node.operation_type == 'query' || node.operation_type.nil?) && context.query.types.query_root.nil?
add_error(GraphQL::StaticValidation::QueryRootExists... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb | Ruby | mit | 5,430 | master | 2,189 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module OneOfInputObjectsAreValid
def on_input_object(node, parent)
return super unless parent.is_a?(GraphQL::Language::Nodes::Argument)
parent_type = get_parent_type(context, parent)
return super unless parent_type... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb | Ruby | mit | 5,430 | master | 717 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FieldsAreDefinedOnTypeError < StaticValidation::Error
attr_reader :type_name
attr_reader :field_name
def initialize(message, path: nil, nodes: [], type:, field:)
super(message, path: path, nodes: nodes)
@... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb | Ruby | mit | 5,430 | master | 1,014 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FragmentsAreOnCompositeTypes
def on_fragment_definition(node, parent)
validate_type_is_composite(node) && super
end
def on_inline_fragment(node, parent)
validate_type_is_composite(node) && super
en... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/mutation_root_exists.rb | Ruby | mit | 5,430 | master | 473 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module MutationRootExists
def on_operation_definition(node, _parent)
if node.operation_type == 'mutation' && context.query.types.mutation_root.nil?
add_error(GraphQL::StaticValidation::MutationRootExistsError.new(
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb | Ruby | mit | 5,430 | master | 4,914 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# Scalars _can't_ have selections
# Objects _must_ have selections
module FieldsHaveAppropriateSelections
include GraphQL::StaticValidation::Error::ErrorHelper
def on_field(node, parent)
if validate_field_selections(... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragment_names_are_unique.rb | Ruby | mit | 5,430 | master | 728 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FragmentNamesAreUnique
def initialize(*)
super
@fragments_by_name = Hash.new { |h, k| h[k] = [] }
end
def on_fragment_definition(node, parent)
@fragments_by_name[node.name] << node
super... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/argument_names_are_unique.rb | Ruby | mit | 5,430 | master | 1,118 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module ArgumentNamesAreUnique
include GraphQL::StaticValidation::Error::ErrorHelper
def on_field(node, parent)
validate_arguments(node)
super
end
def on_directive(node, parent)
validate_arguments... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb | Ruby | mit | 5,430 | master | 676 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class OneOfInputObjectsAreValidError < StaticValidation::Error
attr_reader :input_object_type
def initialize(message, path:, nodes:, input_object_type:)
super(message, path: path, nodes: nodes)
@input_object_type = i... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb | Ruby | mit | 5,430 | master | 864 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FragmentSpreadsArePossibleError < StaticValidation::Error
attr_reader :type_name
attr_reader :fragment_name
attr_reader :parent_name
def initialize(message, path: nil, nodes: [], type:, fragment_name:, parent:)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variables_are_used_and_defined.rb | Ruby | mit | 5,430 | master | 6,083 | # frozen_string_literal: true
module GraphQL
module StaticValidation
# The problem is
# - Variable $usage must be determined at the OperationDefinition level
# - You can't tell how fragments use variables until you visit FragmentDefinitions (which may be at the end of the document)
#
# So, th... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/arguments_are_defined.rb | Ruby | mit | 5,430 | master | 2,402 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module ArgumentsAreDefined
def on_argument(node, parent)
parent_defn = parent_definition(parent)
if parent_defn && @types.argument(parent_defn, node.name)
super
elsif parent_defn
kind_of_node = ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragment_types_exist.rb | Ruby | mit | 5,430 | master | 1,398 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FragmentTypesExist
def on_fragment_definition(node, _parent)
if validate_type_exists(node)
super
end
end
def on_inline_fragment(node, _parent)
if validate_type_exists(node)
su... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb | Ruby | mit | 5,430 | master | 2,236 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module RequiredInputObjectAttributesArePresent
def on_input_object(node, parent)
if parent.is_a? GraphQL::Language::Nodes::Argument
validate_input_object(node, context, parent)
end
super
end
p... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variables_are_input_types_error.rb | Ruby | mit | 5,430 | master | 738 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class VariablesAreInputTypesError < StaticValidation::Error
attr_reader :type_name
attr_reader :variable_name
def initialize(message, path: nil, nodes: [], type:, name:)
super(message, path: path, nodes: nodes)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb | Ruby | mit | 5,430 | master | 762 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FieldsHaveAppropriateSelectionsError < StaticValidation::Error
attr_reader :type_name
attr_reader :node_name
def initialize(message, path: nil, nodes: [], node_name:, type: nil)
super(message, path: path, nodes: ... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragments_are_finite_error.rb | Ruby | mit | 5,430 | master | 624 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FragmentsAreFiniteError < StaticValidation::Error
attr_reader :fragment_name
def initialize(message, path: nil, nodes: [], name:)
super(message, path: path, nodes: nodes)
@fragment_name = name
end
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/operation_names_are_valid.rb | Ruby | mit | 5,430 | master | 1,041 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module OperationNamesAreValid
def initialize(*)
super
@operation_names = Hash.new { |h, k| h[k] = [] }
end
def on_operation_definition(node, parent)
@operation_names[node.name] << node
super
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/operation_names_are_valid_error.rb | Ruby | mit | 5,430 | master | 677 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class OperationNamesAreValidError < StaticValidation::Error
attr_reader :operation_name
def initialize(message, path: nil, nodes: [], name: nil)
super(message, path: path, nodes: nodes)
@operation_name = name
e... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb | Ruby | mit | 5,430 | master | 965 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class RequiredInputObjectAttributesArePresentError < StaticValidation::Error
attr_reader :argument_type
attr_reader :argument_name
attr_reader :input_object_type
def initialize(message, path:, nodes:, argument_type:, arg... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb | Ruby | mit | 5,430 | master | 938 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class VariablesAreUsedAndDefinedError < StaticValidation::Error
attr_reader :variable_name
attr_reader :violation
VIOLATIONS = {
:VARIABLE_NOT_USED => "variableNotUsed",
:VARIABLE_NOT_DEFINED => "variableN... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variable_usages_are_allowed.rb | Ruby | mit | 5,430 | master | 5,588 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module VariableUsagesAreAllowed
def initialize(*)
super
# holds { name => ast_node } pairs
@declared_variables = {}
end
def on_operation_definition(node, parent)
@declared_variables = node.varia... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb | Ruby | mit | 5,430 | master | 1,289 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module VariableDefaultValuesAreCorrectlyTyped
def on_variable_definition(node, parent)
if !node.default_value.nil?
value = node.default_value
type = context.schema.type_from_ast(node.type, context: context)
... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragments_are_finite.rb | Ruby | mit | 5,430 | master | 630 | # frozen_string_literal: true
module GraphQL
module StaticValidation
module FragmentsAreFinite
def on_document(_n, _p)
super
dependency_map = context.dependencies
dependency_map.cyclical_definitions.each do |defn|
if defn.node.is_a?(GraphQL::Language::Nodes::FragmentDefinit... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/not_single_subscription_error.rb | Ruby | mit | 5,430 | master | 523 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class NotSingleSubscriptionError < StaticValidation::Error
def initialize(message, path: nil, nodes: [])
super(message, path: path, nodes: nodes)
end
# A hash representation of this Message
def to_h
exten... |
github | rmosolgo/graphql-ruby | https://github.com/rmosolgo/graphql-ruby | lib/graphql/static_validation/rules/fragment_types_exist_error.rb | Ruby | mit | 5,430 | master | 609 | # frozen_string_literal: true
module GraphQL
module StaticValidation
class FragmentTypesExistError < StaticValidation::Error
attr_reader :type_name
def initialize(message, path: nil, nodes: [], type:)
super(message, path: path, nodes: nodes)
@type_name = type
end
# A hash... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.