Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using object auth on union types is failing #25

Closed
moperacz opened this issue Jun 18, 2020 · 1 comment · Fixed by #26
Closed

using object auth on union types is failing #25

moperacz opened this issue Jun 18, 2020 · 1 comment · Fixed by #26

Comments

@moperacz
Copy link

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?

@moperacz
Copy link
Author

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"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant