Skip to content

Authenticate non-root fields #243

@janosrusiczki

Description

@janosrusiczki

Is it possible to authenticate non-root fields?

After some hurdles I managed to set this gem up with graphql 2.0.14. I got to the point where I set authenticate_default: false in my main schema and if I set authenticate: true on one of the root fields in QueryType I'm getting an error if I want to access it while not being authenticated. However if I add authenticate: true to one of the non-root fields it doesn't seem to have any effect.

In my case I have:

# ./app/graphql/types/photo_type.rb
module Types
  class PhotoType < GraphQL::Schema::Object
    field_class GraphqlDevise::Types::BaseField

    description 'A Photo'

    field :id, String, null: false, authenticate: true
    [ snip ]
  end
end

I can access id without being authenticated.

Is it possible to have this type of granular authentication? If yes, what am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions