Remove Album.coverID + fix thumbnail refresh
- Album.coverID has been removed from `schema.graphql` - Make sure the proper informations are fetched from the set/reset album cover mutations such that Apollo can update the cache accordingly.
This commit is contained in:
parent
5610fe0c00
commit
feeb9e0a40
|
@ -57,7 +57,6 @@ type DirectiveRoot struct {
|
|||
|
||||
type ComplexityRoot struct {
|
||||
Album struct {
|
||||
CoverID func(childComplexity int) int
|
||||
FilePath func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Media func(childComplexity int, order *models.Ordering, paginate *models.Pagination, onlyFavorites *bool) int
|
||||
|
@ -371,13 +370,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||
_ = ec
|
||||
switch typeName + "." + field {
|
||||
|
||||
case "Album.coverID":
|
||||
if e.complexity.Album.CoverID == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Album.CoverID(childComplexity), true
|
||||
|
||||
case "Album.filePath":
|
||||
if e.complexity.Album.FilePath == nil {
|
||||
break
|
||||
|
@ -1947,7 +1939,7 @@ type Album {
|
|||
|
||||
shares: [ShareToken!]!
|
||||
|
||||
coverID: Int
|
||||
#coverID: Int
|
||||
}
|
||||
|
||||
type MediaURL {
|
||||
|
@ -3337,38 +3329,6 @@ func (ec *executionContext) _Album_shares(ctx context.Context, field graphql.Col
|
|||
return ec.marshalNShareToken2ᚕᚖgithubᚗcomᚋphotoviewᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐShareTokenᚄ(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Album_coverID(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
fc := &graphql.FieldContext{
|
||||
Object: "Album",
|
||||
Field: field,
|
||||
Args: nil,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
}
|
||||
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.CoverID, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*int)
|
||||
fc.Result = res
|
||||
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _AuthorizeResult_success(ctx context.Context, field graphql.CollectedField, obj *models.AuthorizeResult) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
@ -10361,8 +10321,6 @@ func (ec *executionContext) _Album(ctx context.Context, sel ast.SelectionSet, ob
|
|||
}
|
||||
return res
|
||||
})
|
||||
case "coverID":
|
||||
out.Values[i] = ec._Album_coverID(ctx, field, obj)
|
||||
default:
|
||||
panic("unknown field " + strconv.Quote(field.Name))
|
||||
}
|
||||
|
|
|
@ -278,8 +278,6 @@ type Album {
|
|||
path: [Album!]!
|
||||
|
||||
shares: [ShareToken!]!
|
||||
|
||||
coverID: Int
|
||||
}
|
||||
|
||||
type MediaURL {
|
||||
|
|
|
@ -25,6 +25,7 @@ const ALBUM_QUERY = gql`
|
|||
id
|
||||
title
|
||||
thumbnail {
|
||||
id
|
||||
thumbnail {
|
||||
url
|
||||
}
|
||||
|
@ -93,7 +94,6 @@ function AlbumPage({ match }: AlbumPageProps) {
|
|||
offset: 0,
|
||||
limit: 200,
|
||||
},
|
||||
fetchPolicy: 'network-only',
|
||||
})
|
||||
|
||||
const { containerElem, finished: finishedLoadingMore } =
|
||||
|
|
|
@ -19,6 +19,7 @@ export interface albumQuery_album_subAlbums_thumbnail_thumbnail {
|
|||
|
||||
export interface albumQuery_album_subAlbums_thumbnail {
|
||||
__typename: 'Media'
|
||||
id: string
|
||||
/**
|
||||
* URL to display the media in a smaller resolution
|
||||
*/
|
||||
|
|
|
@ -10,6 +10,7 @@ const getAlbumsQuery = gql`
|
|||
id
|
||||
title
|
||||
thumbnail {
|
||||
id
|
||||
thumbnail {
|
||||
url
|
||||
}
|
||||
|
@ -19,9 +20,7 @@ const getAlbumsQuery = gql`
|
|||
`
|
||||
|
||||
const AlbumsPage = () => {
|
||||
const { error, data } = useQuery<getMyAlbums>(getAlbumsQuery, {
|
||||
fetchPolicy: 'network-only',
|
||||
})
|
||||
const { error, data } = useQuery<getMyAlbums>(getAlbumsQuery)
|
||||
|
||||
return (
|
||||
<Layout title="Albums">
|
||||
|
|
|
@ -8,34 +8,35 @@
|
|||
// ====================================================
|
||||
|
||||
export interface getMyAlbums_myAlbums_thumbnail_thumbnail {
|
||||
__typename: "MediaURL";
|
||||
__typename: 'MediaURL'
|
||||
/**
|
||||
* URL for previewing the image
|
||||
*/
|
||||
url: string;
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface getMyAlbums_myAlbums_thumbnail {
|
||||
__typename: "Media";
|
||||
__typename: 'Media'
|
||||
id: string
|
||||
/**
|
||||
* URL to display the media in a smaller resolution
|
||||
*/
|
||||
thumbnail: getMyAlbums_myAlbums_thumbnail_thumbnail | null;
|
||||
thumbnail: getMyAlbums_myAlbums_thumbnail_thumbnail | null
|
||||
}
|
||||
|
||||
export interface getMyAlbums_myAlbums {
|
||||
__typename: "Album";
|
||||
id: string;
|
||||
title: string;
|
||||
__typename: 'Album'
|
||||
id: string
|
||||
title: string
|
||||
/**
|
||||
* An image in this album used for previewing this album
|
||||
*/
|
||||
thumbnail: getMyAlbums_myAlbums_thumbnail | null;
|
||||
thumbnail: getMyAlbums_myAlbums_thumbnail | null
|
||||
}
|
||||
|
||||
export interface getMyAlbums {
|
||||
/**
|
||||
* List of albums owned by the logged in user.
|
||||
*/
|
||||
myAlbums: getMyAlbums_myAlbums[];
|
||||
myAlbums: getMyAlbums_myAlbums[]
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ export const SHARE_ALBUM_QUERY = gql`
|
|||
id
|
||||
title
|
||||
thumbnail {
|
||||
id
|
||||
thumbnail {
|
||||
url
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ export interface shareAlbumQuery_album_subAlbums_thumbnail_thumbnail {
|
|||
|
||||
export interface shareAlbumQuery_album_subAlbums_thumbnail {
|
||||
__typename: 'Media'
|
||||
id: string
|
||||
/**
|
||||
* URL to display the media in a smaller resolution
|
||||
*/
|
||||
|
|
|
@ -17,13 +17,25 @@ const RESET_ALBUM_COVER_MUTATION = gql`
|
|||
mutation resetAlbumCover($albumID: ID!) {
|
||||
resetAlbumCover(albumID: $albumID) {
|
||||
id
|
||||
thumbnail {
|
||||
id
|
||||
thumbnail {
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const SET_ALBUM_COVER_MUTATION = gql`
|
||||
mutation setAlbumCover($coverID: ID!) {
|
||||
setAlbumCover(coverID: $coverID) {
|
||||
coverID
|
||||
id
|
||||
thumbnail {
|
||||
id
|
||||
thumbnail {
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
@ -7,9 +7,30 @@
|
|||
// GraphQL mutation operation: resetAlbumCover
|
||||
// ====================================================
|
||||
|
||||
export interface resetAlbumCover_resetAlbumCover_thumbnail_thumbnail {
|
||||
__typename: 'MediaURL'
|
||||
/**
|
||||
* URL for previewing the image
|
||||
*/
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface resetAlbumCover_resetAlbumCover_thumbnail {
|
||||
__typename: 'Media'
|
||||
id: string
|
||||
/**
|
||||
* URL to display the media in a smaller resolution
|
||||
*/
|
||||
thumbnail: resetAlbumCover_resetAlbumCover_thumbnail_thumbnail | null
|
||||
}
|
||||
|
||||
export interface resetAlbumCover_resetAlbumCover {
|
||||
__typename: 'Album'
|
||||
id: string
|
||||
/**
|
||||
* An image in this album used for previewing this album
|
||||
*/
|
||||
thumbnail: resetAlbumCover_resetAlbumCover_thumbnail | null
|
||||
}
|
||||
|
||||
export interface resetAlbumCover {
|
||||
|
|
|
@ -7,9 +7,30 @@
|
|||
// GraphQL mutation operation: setAlbumCover
|
||||
// ====================================================
|
||||
|
||||
export interface setAlbumCover_setAlbumCover_thumbnail_thumbnail {
|
||||
__typename: 'MediaURL'
|
||||
/**
|
||||
* URL for previewing the image
|
||||
*/
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface setAlbumCover_setAlbumCover_thumbnail {
|
||||
__typename: 'Media'
|
||||
id: string
|
||||
/**
|
||||
* URL to display the media in a smaller resolution
|
||||
*/
|
||||
thumbnail: setAlbumCover_setAlbumCover_thumbnail_thumbnail | null
|
||||
}
|
||||
|
||||
export interface setAlbumCover_setAlbumCover {
|
||||
__typename: 'Album'
|
||||
coverID: number
|
||||
id: string
|
||||
/**
|
||||
* An image in this album used for previewing this album
|
||||
*/
|
||||
thumbnail: setAlbumCover_setAlbumCover_thumbnail | null
|
||||
}
|
||||
|
||||
export interface setAlbumCover {
|
||||
|
|
Loading…
Reference in New Issue