Class: GraphAttack::RateLimit
- Inherits:
-
GraphQL::Schema::FieldExtension
- Object
- GraphQL::Schema::FieldExtension
- GraphAttack::RateLimit
- Defined in:
- lib/graph_attack/rate_limit.rb
Instance Method Summary collapse
Instance Method Details
#resolve(object:, arguments:, **_rest) {|object, arguments| ... } ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/graph_attack/rate_limit.rb', line 5 def resolve(object:, arguments:, **_rest) rate_limited_field = object.context[on] unless object.context.key?(on) raise GraphAttack::Error, "Missing :#{on} key on the GraphQL context" end if rate_limited_field && calls_exceeded_on_query?(rate_limited_field) return RateLimited.new('Query rate limit exceeded') end yield(object, arguments) end |