Files
speckle-server/modules/core/graph/schemas/streams.graphql
T
izzy lyseggen 6db1bdcf42 feat(subs): simplify stream create/delete subs
as per discussion, remove `ownerId` input and only allow subscribing to
your own stream creation / deletion
2020-08-21 13:44:19 +01:00

137 lines
3.3 KiB
GraphQL
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
extend type Query {
stream( id: String! ): Stream
@hasScope(scope: "streams:write")
"""
All the streams of the current user, pass in the `query` parameter to seach by name, description or ID.
"""
streams( query: String!, limit: Int! = 25, cursor: String ): StreamCollection
}
type Stream {
id: String!
name: String!
description: String
isPublic: Boolean!
createdAt: String!
updatedAt: String!
collaborators: [ StreamCollaborator ]!
}
extend type User {
"""
All the streams that a user has access to.
"""
streams( limit: Int! = 25, cursor: String ): StreamCollection
}
type StreamCollaborator {
id: String!
name: String!
role: String!
}
type StreamCollection {
totalCount: Int!
cursor: String
items: [ Stream ]
}
extend type Mutation {
"""
Creates a new stream.
"""
streamCreate( stream: StreamCreateInput! ): String
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
"""
Updates an existing stream.
"""
streamUpdate( stream: StreamUpdateInput! ): Boolean!
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
"""
Deletes an existing stream.
"""
streamDelete( id: String! ): Boolean!
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
"""
Grants permissions to a user on a given stream.
"""
streamGrantPermission( streamId: String!, userId: String!, role: String! ): Boolean
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
"""
Revokes the permissions of a user on a given stream.
"""
streamRevokePermission( streamId: String!, userId: String! ): Boolean
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
}
extend type Subscription {
#
# User bound subscriptions that operate on the stream collection of an user
# Example relevant view/usecase: updates when working in GH or Dynamo
#
# Source:
# - stream created mutation (target: stream creator)
# - stream grant permissions (target: grantee id)
#
# Payload: streamId and sreamCreate input args
# 
# As per discussion, removed `ownerId` input so this now just works for the current user
"""
Subscribes to new stream created event for a given user.
"""
userStreamCreated: JSONObject
@hasRole(role: "server:user")
@hasScope(scope: "profile:read")
# Source:
# - stream delete mutation (target: all stream users in acl)
# - stream revoke permissions (target: grantee id)
#
# Payload: streamId
"""
Subscribes to stream deleted event for a given user.
"""
userStreamDeleted: JSONObject
@hasRole(role: "server:user")
@hasScope(scope: "profile:read")
"""
Subscribes to stream updated event.
"""
streamUpdated( streamId: String ): JSONObject
@hasRole(role: "server:user")
@hasScope(scope: "streams:read")
"""
Subscribes to stream permission granted event.
"""
streamPermissionGranted( userId: String! ): JSONObject
@hasRole(role: "server:user")
@hasScope(scope: "profile:read")
"""
Subscribes to stream delete event.
"""
streamPermissionRevoked( userId: String! ): JSONObject
@hasRole(role: "server:user")
@hasScope(scope: "profile:read")
}
input StreamCreateInput {
name: String
description: String
isPublic: Boolean
}
input StreamUpdateInput {
id: String!
name: String
description: String
isPublic: Boolean
}