jungsoft/rajska

using object auth on `union` types is failing

moperacz opened this issue · 1 comments

with (KeyError) key :type not found

in Rajska.ObjectAuthorization.find_associations/2 there is

authorize(schema_node.type, selections ++ tail, resolution)

but union type do not have :type key (as the type of this type is dynamic)

any workarounds, pointers?

example object "from union" type:

%Absinthe.Type.Object{
  __private__: [meta: [authorize: [:user, :admin]]],
  __reference__: %{
    identifier: :locked_mirror,
    location: %{
      file: "/Users/misiek/Documents/projects/mink_umbrella/apps/graphql/lib/graph_ql/observations/types.ex",
      line: 66
    },
    module: GraphQL.Observations.Types
  },
  description: nil,
  field_imports: [],
  fields: %{
    still_required: %Absinthe.Type.Field{
      __private__: [],
      __reference__: %{
        identifier: :still_required,
        location: %{
          file: "/Users/misiek/Documents/projects/mink_umbrella/apps/graphql/lib/graph_ql/observations/types.ex",
          line: 68
        },
        module: GraphQL.Observations.Types
      },
      args: %{},
      complexity: nil,
      config: nil,
      default_value: nil,
      deprecation: nil,
      description: nil,
      identifier: :still_required,
      middleware: [
        {{Rajska.FieldAuthorization, :call},
         [
           object: %Absinthe.Type.Object{
             __private__: [meta: [authorize: [:user, :admin]]],
             __reference__: %{
               identifier: :locked_mirror,
               location: %{
                 file: "/Users/misiek/Documents/projects/mink_umbrella/apps/graphql/lib/graph_ql/observations/types.ex",
                 line: 66
               },
               module: GraphQL.Observations.Types
             },
             description: nil,
             field_imports: [],
             fields: %{
               still_required: %Absinthe.Type.Field{
                 __private__: [],
                 __reference__: %{
                   identifier: :still_required,
                   location: %{
                     file: "/Users/misiek/Documents/projects/mink_umbrella/apps/graphql/lib/graph_ql/observations/types.ex",
                     line: 68
                   },
                   module: GraphQL.Observations.Types
                 },
                 args: %{},
                 complexity: nil,
                 config: nil,
                 default_value: nil,
                 deprecation: nil,
                 description: nil,
                 identifier: :still_required,
                 middleware: [],
                 name: "still_required",
                 triggers: [],
                 type: :integer
               }
             },
             identifier: :locked_mirror,
             interfaces: [],
             is_type_of: nil,
             name: "LockedMirror"
           },
           field: :still_required
         ]},
        {Absinthe.Middleware.MapGet, :still_required}
      ],
      name: "still_required",
      triggers: [],
      type: :integer
    }
  },
  identifier: :locked_mirror,
  interfaces: [],
  is_type_of: nil,
  name: "LockedMirror"
}