Module: GraphQL::Authorization::Analyzer Deprecated
- Defined in:
- lib/graphql/authorization.rb
Overview
Deprecated.
authorization at query runtime is generally a better idea.
Class Method Summary collapse
- .call(memo, visit_type, irep_node) ⇒ Object
- .final_value(memo) ⇒ Object
- .initial_value(query) ⇒ Object
Class Method Details
.call(memo, visit_type, irep_node) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/graphql/authorization.rb', line 34 def call(memo, visit_type, irep_node) if visit_type == :enter field = irep_node.definition if field schema = memo[:schema] ctx = memo[:context] next_field_accessible = schema.accessible?(field, ctx) if !next_field_accessible memo[:inaccessible_nodes] << irep_node else arg_accessible = true irep_node.arguments.argument_values.each do |name, arg_value| arg_accessible = schema.accessible?(arg_value.definition, ctx) if !arg_accessible memo[:inaccessible_nodes] << irep_node break end end if arg_accessible return_type = field.type.unwrap next_type_accessible = schema.accessible?(return_type, ctx) if !next_type_accessible memo[:inaccessible_nodes] << irep_node end end end end end memo end |
.final_value(memo) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/graphql/authorization.rb', line 65 def final_value(memo) nodes = memo[:inaccessible_nodes] if nodes.any? fields = nodes.map do |node| field_inst = node.definition # Get the "source of truth" for this field field_inst.[:type_class] || field_inst end context = memo[:context] err = InaccessibleFieldsError.new(fields: fields, irep_nodes: nodes, context: context) context.schema.inaccessible_fields(err) else nil end end |
.initial_value(query) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/graphql/authorization.rb', line 26 def initial_value(query) { schema: query.schema, context: query.context, inaccessible_nodes: [], } end |