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:
@ -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)
|
||||
}
|
||||
|
||||
@ -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 = {
|
||||
|
||||
@ -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
|
||||
}
|
||||
`
|
||||
|
||||
@ -41,15 +41,6 @@ export async function mergeHighlightMutation(
|
||||
updatedAt
|
||||
annotation
|
||||
sharedAt
|
||||
user {
|
||||
id
|
||||
name
|
||||
profile {
|
||||
id
|
||||
pictureUrl
|
||||
username
|
||||
}
|
||||
}
|
||||
createdByMe
|
||||
}
|
||||
overlapHighlightIdList
|
||||
|
||||
Reference in New Issue
Block a user