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: a given user's profile page. # # Source: # - stream created mutation (target: stream creator) # - stream grant permissions (target: grantee id) # # Payload: maybe just the streamId? as this event will trigger a new call to get the user's streams on the client side? #  # TODO: scope check: if context.userId === variables.userId -> profile:read; otherwise users:read # Q: make the arg optional; if not present -> default to context.user? """ Subscribes to new stream created event for a given user. """ userStreamCreated( ownerId: String! ): 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: maybe just the streamId? as this event will trigger a new call to get the user's streams on the client side? """ Subscribes to stream deleted event for a given user. """ userStreamDeleted( ownerId: String! ): JSONObject @hasRole(role: "server:user") @hasScope(scope: "profile:read") """ Subscribes to stream updated event. """ streamUpdated( streamId: String! ): JSONObject @hasRole(role: "server:user") """ Subscribes to stream permission granted event. """ streamPermissionGranted( userId: String! ): JSONObject @hasRole(role: "server:user") """ Subscribes to stream delete event. """ streamPermissionRevoked( userId: String! ): JSONObject @hasRole(role: "server:user") } input StreamCreateInput { name: String description: String isPublic: Boolean } input StreamUpdateInput { id: String! name: String description: String isPublic: Boolean }