Class: GraphQL::PersistedQueries::Analyzers::HttpMethodValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/persisted_queries/analyzers/http_method_validator.rb

Overview

Verifies that mutations are not executed using GET requests

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ HttpMethodValidator

Returns a new instance of HttpMethodValidator.



8
9
10
# File 'lib/graphql/persisted_queries/analyzers/http_method_validator.rb', line 8

def initialize(query)
  @query = query
end

Instance Method Details

#performObject



12
13
14
15
16
# File 'lib/graphql/persisted_queries/analyzers/http_method_validator.rb', line 12

def perform
  return if !@query.context[:request]&.get? || !@query.mutation?

  GraphQL::AnalysisError.new("Mutations cannot be performed via HTTP GET")
end