graphiti 1.2.25 → 1.2.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphiti/errors.rb +14 -0
- data/lib/graphiti/resource/interface.rb +10 -0
- data/lib/graphiti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 872977a69e5cb7a4fd2cbe93953be2dbba89868f3c41267b8a72ce22ffb5c600
|
4
|
+
data.tar.gz: 2d189dcaa525e2d5a1b2ffd752a53cc28e0e381cb2411d8530e750175f9de92c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e3b922df304f43f3404db5e0213dce76bd073d6d226a3c62620fc5ff0198c2a13a6c7ed3b48b92421cfb6396acb31c11e84edb099bdab915cc9b8917baa845b
|
7
|
+
data.tar.gz: 80a5f5f23638c598c64012032a7ab4aea3fc5ce515f6b72f9bdf93f19c1c50ee3fd9fd373a6ccec34e4f84f6cf3217257d10d93b4a870aa06e91be67e610c8b0
|
data/lib/graphiti/errors.rb
CHANGED
@@ -366,6 +366,20 @@ module Graphiti
|
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
369
|
+
class UndefinedIDLookup < Base
|
370
|
+
def initialize(resource_class)
|
371
|
+
@resource_class = resource_class
|
372
|
+
end
|
373
|
+
|
374
|
+
def message
|
375
|
+
<<~MSG
|
376
|
+
Tried to resolve #{@resource_class} with an :id filter, but the filter was nil.
|
377
|
+
This can result in unscoping a query, which can cause incorrect values to be
|
378
|
+
returned which may or may not bypass standard access controls.
|
379
|
+
MSG
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
369
383
|
class UnknownAttribute < AttributeError
|
370
384
|
def message
|
371
385
|
"#{super}, but could not find an attribute with that name."
|
@@ -23,6 +23,9 @@ module Graphiti
|
|
23
23
|
|
24
24
|
# @api private
|
25
25
|
def _find(params = {}, base_scope = nil)
|
26
|
+
guard_nil_id!(params[:data])
|
27
|
+
guard_nil_id!(params)
|
28
|
+
|
26
29
|
id = params[:data].try(:[], :id) || params.delete(:id)
|
27
30
|
params[:filter] ||= {}
|
28
31
|
params[:filter][:id] = id if id
|
@@ -52,6 +55,13 @@ module Graphiti
|
|
52
55
|
end
|
53
56
|
end
|
54
57
|
end
|
58
|
+
|
59
|
+
def guard_nil_id!(params)
|
60
|
+
return unless params
|
61
|
+
if params.key?(:id) && params[:id].nil?
|
62
|
+
raise Errors::UndefinedIDLookup.new(self)
|
63
|
+
end
|
64
|
+
end
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
data/lib/graphiti/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|