Reduce the data fetched when creating highlights

This reduces the fields on the highlight type, and reduces what
we fetch. We are doing this so its easier to bind from Swift and
pass back simpler types for create/update/merge highlight
operations
This commit is contained in:
Jackson Harper
2022-03-24 09:54:59 -07:00
parent 134264940f
commit f3edb9ca7a
4 changed files with 13 additions and 59 deletions

View File

@ -67,12 +67,16 @@ function nodeAttributesFromHighlight(
const patch = highlight.patch
const id = highlight.id
const withNote = !!highlight.annotation
const customColor = !highlight.createdByMe
? stringToColour(highlight.user.profile.username)
: undefined
const tooltip = !highlight.createdByMe
? `Created by: @${highlight.user.profile.username}`
: undefined
const customColor = undefined
const tooltip = undefined
// We've disabled shared highlights, so passing undefined
// here now, and removing the user object from highlights
// !highlight.createdByMe
// ? stringToColour(highlight.user.profile.username)
// : undefined
// const tooltip = !highlight.createdByMe
// ? `Created by: @${highlight.user.profile.username}`
// : undefined
return makeHighlightNodeAttributes(patch, id, withNote, customColor, tooltip)
}

View File

@ -9,18 +9,6 @@ export const highlightFragment = gql`
suffix
patch
annotation
createdAt
updatedAt
sharedAt
user {
id
name
profile {
id
pictureUrl
username
}
}
createdByMe
}
`
@ -33,11 +21,7 @@ export type Highlight = {
suffix?: string
patch: string
annotation?: string
createdAt: string
updatedAt: string
user: User
createdByMe: boolean
sharedAt?: string
}
export type User = {

View File

@ -1,6 +1,6 @@
import { gql } from 'graphql-request'
import { gqlFetcher } from '../networkHelpers'
import { Highlight } from './../fragments/highlightFragment'
import { Highlight, highlightFragment } from './../fragments/highlightFragment'
export type CreateHighlightInput = {
prefix: string
@ -28,7 +28,7 @@ export async function createHighlightMutation(
createHighlight(input: $input) {
... on CreateHighlightSuccess {
highlight {
...NewHighlight
...HighlightFields
}
}
@ -37,7 +37,7 @@ export async function createHighlightMutation(
}
}
}
${NewHighlightFragment}
${highlightFragment}
`
try {
@ -48,28 +48,3 @@ export async function createHighlightMutation(
return undefined
}
}
const NewHighlightFragment = gql`
fragment NewHighlight on Highlight {
id
shortId
quote
prefix
suffix
patch
createdAt
updatedAt
annotation
sharedAt
user {
id
name
profile {
id
pictureUrl
username
}
}
createdByMe
}
`

View File

@ -41,15 +41,6 @@ export async function mergeHighlightMutation(
updatedAt
annotation
sharedAt
user {
id
name
profile {
id
pictureUrl
username
}
}
createdByMe
}
overlapHighlightIdList