Skip to main content

Database resolvers

Resolvers#

Resolvers are functions that fetch data based on parameters. Resolves are provided by the user.

Required fetch resolvers#

  • user(id: ID!): User Fetches a user based on provided user id

  • userWithEmail(email: string): User Fetches a user based on provided user email

  • annotation(id: ID!): Annotation Fetches an annotation based on provided annotation id

  • document(id: ID!): Document Fetches a document based on provided document id

  • annotationMember(id: ID!): AnnotationMember Fetches a member based on provided annotationMember id

  • documentMember(id: ID!): DocumentMember Fetches a member based on provided documentMember id

Optional fetch resolvers#

These resolvers are not required but are recommended for performance reasons. If these resolvers are not defined the app will fall back to the required resolvers, which may be inefficient, as it would require multiple database requests rather than just one.

  • users(ids: [ID!]!): [User!]! Fetches a group of users based on provided IDs. Falls back to looping over the user resolver if not defined.

  • annotations(ids: [ID!]!): [Annotation!]! Fetches a group of annotations based on provided IDs. Falls back to looping over the annotation resolver if not defined.

  • annotationMembers(ids: [ID!]!): [AnnotationMember!]! Fetches members based on provided annotationMember id

  • documentMembers(ids: [ID!]!): [DocumentMember!]! Fetches members based on provided documentMember id

  • userDocuments(userId: ID!): [Document] Fetches all documents belong to provided user

Mutations#

Mutations are functions that modify data, they are implemented to cause a data write.

  • addUser(input: NewUserInput!): User!: Create a new user.

  • editUser(id: ID!, input: EditUserInput!): StandardUser!: Edit existing user by user id.

  • deleteUser(id: ID! ): DeleteResult!: Deactivate existing user by user id. This will change the status of user to INACTIVE.

  • addAnnotation(input: NewAnnotationInput!): Annotation!: Create a new annotation.

  • editAnnotation(id:ID!, input: EditAnnotationInput!): Annotation!: Editing annotation by annotation id.

  • deleteAnnotation(id: ID!, input: DeleteAnnotationInput!): DeleteResult!: Delete annotation by annotation id, this will also delete all of its annotation members.

  • addAnnotationMember(input: NewAnnotationMemberInput!): AnnotationMember!: Create new annotation member to link the annotation, the member of the annotation and the document it belong to.

  • editAnnotationMember(id: ID!, input: EditAnnotationMemberInput!): AnnotationMember!: Edit the annotation member by annotation member id

  • deleteAnnotationMember(id: ID!): DeleteResult!: Delete the annotation member

  • updateAnnotationMemberLastRead(memberId: ID!): AnnotationMember!: Update the lastRead timestamp of annotation member.

  • addDocument(document: NewDocumentInput!): Document!: Create new document.

  • editDocument(id: ID! input: EditDocumentInput): Document!: Edit document by document id.

  • deleteDocument(id: ID!): DeleteResult!: Delete document, this will also delete all of its document members.

  • addDocumentMember(input: NewDocumentMemberInput!): DocumentMember!: Create new document member to link the document and the member of the document.

  • deleteDocumentMember(id: ID!): DeleteResult!: Delete document member by document member id.

  • updateDocumentMemberLastRead(memberId: ID!): DocumentMember!: Update the lastRead timestamp of document member.

  • removeDocumentFromUser(documentId: ID!, userId: ID!): User!: Delete document member by document id and user id.