Files
probo/pkg/server/gqlutils/directives/authentication/schema.graphql
Bryan Frimin 383ea5a2d4 Retrict some query and mutation to only session
Signed-off-by: Bryan Frimin <bryan@probo.com>
2026-06-02 17:43:21 -07:00

40 lines
1.3 KiB
GraphQL

# Authentication directive for GraphQL APIs
# Include this schema in your gqlgen configuration to enable identity-based
# access control (session OR API key).
#
# Usage in your schema.graphql:
# type Query {
# viewer: User @authentication(required: PRESENT)
# publicData: Data @authentication(required: OPTIONAL)
# signup(input: SignUpInput!): SignUpPayload @authentication(required: NONE)
# }
directive @authentication(required: AuthenticationRequirement!) on FIELD_DEFINITION
enum AuthenticationRequirement
@goModel(
model: "go.probo.inc/probo/pkg/server/gqlutils/directives/authentication.AuthenticationRequirement"
) {
"""
Requires an authenticated identity (session or API key).
"""
PRESENT
@goEnum(
value: "go.probo.inc/probo/pkg/server/gqlutils/directives/authentication.AuthenticationRequirementPresent"
)
"""
Forbids authenticated access (e.g., for login/signup endpoints).
"""
NONE
@goEnum(
value: "go.probo.inc/probo/pkg/server/gqlutils/directives/authentication.AuthenticationRequirementNone"
)
"""
Allows both authenticated and unauthenticated access.
"""
OPTIONAL
@goEnum(
value: "go.probo.inc/probo/pkg/server/gqlutils/directives/authentication.AuthenticationRequirementOptional"
)
}