Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AB#44000] Toast notifications for entity actions #304

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions services/media/service/src/generated/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11503,7 +11503,6 @@ type IngestDocument {
createdUser: String!
updatedUser: String!
status: IngestStatus!
startedCount: Int!

"""Reads and enables pagination through a set of `IngestItem`."""
ingestItems(
Expand Down Expand Up @@ -12390,9 +12389,6 @@ input IngestDocumentFilter {
"""Filter by the object’s `status` field."""
status: IngestStatusFilter

"""Filter by the object’s `startedCount` field."""
startedCount: IntFilter

"""Filter by the object’s `ingestItems` relation."""
ingestItems: IngestDocumentToManyIngestItemFilter

Expand Down Expand Up @@ -12667,8 +12663,6 @@ enum IngestDocumentsOrderBy {
UPDATED_USER_DESC
STATUS_ASC
STATUS_DESC
STARTED_COUNT_ASC
STARTED_COUNT_DESC
PRIMARY_KEY_ASC
PRIMARY_KEY_DESC
}
Expand Down Expand Up @@ -12726,9 +12720,6 @@ input IngestDocumentCondition {

"""Checks for equality with the object’s `status` field."""
status: IngestStatus

"""Checks for equality with the object’s `startedCount` field."""
startedCount: Int
}

"""
Expand Down Expand Up @@ -14863,19 +14854,19 @@ type Mutation {
publishCollection(
"""ID of the collection to publish."""
collectionId: Int!
): Snapshot
): Snapshot!

"""Unpublishes the currently published Collection snapshot."""
unpublishCollection(
"""ID of the collection to unpublish."""
collectionId: Int!
): Snapshot
): Snapshot!

"""Creates a new Collection snapshot."""
createCollectionSnapshot(
"""ID of the collection to create a snapshot from."""
collectionId: Int!
): Snapshot
): Snapshot!
deleteCollections(filter: CollectionFilter): BulkMutationIntPayload
deleteCollectionRelations(filter: CollectionRelationFilter): BulkMutationIntPayload
createMovieSnapshots(
Expand All @@ -14895,33 +14886,33 @@ type Mutation {
publishMovie(
"""ID of the movie to publish."""
movieId: Int!
): Snapshot
): Snapshot!

"""Unpublishes the currently published Movie snapshot."""
unpublishMovie(
"""ID of the movie to unpublish."""
movieId: Int!
): Snapshot
): Snapshot!

"""Creates a new Movie snapshot."""
createMovieSnapshot(
"""ID of the movie to create a snapshot from."""
movieId: Int!
): Snapshot
): Snapshot!
deleteMoviesLicenses(filter: MoviesLicenseFilter): BulkMutationIntPayload
deleteMovieGenres(filter: MovieGenreFilter): BulkMutationIntPayload
deleteMovies(filter: MovieFilter): BulkMutationIntPayload

"""
Creates a Movie genres snapshot and immediately publishes it if it's valid.
"""
publishMovieGenres: Snapshot
publishMovieGenres: Snapshot!

"""Unpublishes the currently published Movie genres snapshot."""
unpublishMovieGenres: Snapshot
unpublishMovieGenres: Snapshot!

"""Creates a new Movie genres snapshot."""
createMovieGenresSnapshot: Snapshot
createMovieGenresSnapshot: Snapshot!
createEpisodeSnapshots(
"""Filter for bulk selecting items."""
filter: EpisodeFilter
Expand Down Expand Up @@ -14963,55 +14954,55 @@ type Mutation {
publishTvshow(
"""ID of the tvshow to publish."""
tvshowId: Int!
): Snapshot
): Snapshot!

"""Unpublishes the currently published Tvshow snapshot."""
unpublishTvshow(
"""ID of the tvshow to unpublish."""
tvshowId: Int!
): Snapshot
): Snapshot!

"""Creates a new Tvshow snapshot."""
createTvshowSnapshot(
"""ID of the tvshow to create a snapshot from."""
tvshowId: Int!
): Snapshot
): Snapshot!

"""Creates a Season snapshot and immediately publishes it if it's valid."""
publishSeason(
"""ID of the season to publish."""
seasonId: Int!
): Snapshot
): Snapshot!

"""Unpublishes the currently published Season snapshot."""
unpublishSeason(
"""ID of the season to unpublish."""
seasonId: Int!
): Snapshot
): Snapshot!

"""Creates a new Season snapshot."""
createSeasonSnapshot(
"""ID of the season to create a snapshot from."""
seasonId: Int!
): Snapshot
): Snapshot!

"""Creates a Episode snapshot and immediately publishes it if it's valid."""
publishEpisode(
"""ID of the episode to publish."""
episodeId: Int!
): Snapshot
): Snapshot!

"""Unpublishes the currently published Episode snapshot."""
unpublishEpisode(
"""ID of the episode to unpublish."""
episodeId: Int!
): Snapshot
): Snapshot!

"""Creates a new Episode snapshot."""
createEpisodeSnapshot(
"""ID of the episode to create a snapshot from."""
episodeId: Int!
): Snapshot
): Snapshot!
deleteTvshowsLicenses(filter: TvshowsLicenseFilter): BulkMutationIntPayload
deleteSeasonsLicenses(filter: SeasonsLicenseFilter): BulkMutationIntPayload
deleteEpisodesLicenses(filter: EpisodesLicenseFilter): BulkMutationIntPayload
Expand All @@ -15023,13 +15014,13 @@ type Mutation {
"""
Creates a Tvshow genres snapshot and immediately publishes it if it's valid.
"""
publishTvshowGenres: Snapshot
publishTvshowGenres: Snapshot!

"""Unpublishes the currently published Tvshow genres snapshot."""
unpublishTvshowGenres: Snapshot
unpublishTvshowGenres: Snapshot!

"""Creates a new Tvshow genres snapshot."""
createTvshowGenresSnapshot: Snapshot
createTvshowGenresSnapshot: Snapshot!
populateCollections(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
import { MosaicError } from '@axinom/mosaic-service-common';
import { Plugin } from 'graphile-build';
import { GraphileHelpers } from 'graphile-utils/node8plus/fieldHelpers';
import { GraphQLFieldConfig, GraphQLObjectType } from 'graphql';
import {
GraphQLFieldConfig,
GraphQLNonNull,
GraphQLNullableType,
} from 'graphql';
import { humanize } from 'inflection';
import {
MediaServiceMessagingSettings,
Expand Down Expand Up @@ -38,15 +42,16 @@ import {
export const EntityListPublishingEndpointsPluginFactory = (
info: EntityListInfo,
): Plugin => {
let outType: GraphQLObjectType;
let outType: GraphQLNonNull<GraphQLNullableType>;

return (builder) => {
builder.hook('init', (input, build, _context) => {
outType = getTableGqlType(build, 'snapshots');
if (build.getTypeByName(outType.name) === undefined) {
const nullableType = getTableGqlType(build, 'snapshots');
outType = new GraphQLNonNull(nullableType as GraphQLNullableType);
if (build.getTypeByName(nullableType.name) === undefined) {
build.newWithHooks(
build.graphql.GraphQLObjectType,
outType.toConfig(),
nullableType.toConfig(),
{},
);
}
Expand Down Expand Up @@ -76,7 +81,7 @@ export const EntityListPublishingEndpointsPluginFactory = (
ownerPool,
jwtToken,
config,
storeInboxMessage,
storeOutboxMessage,
} = getValidatedExtendedContext(context);
const pgSettings = buildPgSettings(
subject,
Expand All @@ -96,7 +101,7 @@ export const EntityListPublishingEndpointsPluginFactory = (
generateSnapshotJobId(),
ctx,
);
await storeInboxMessage<PublishEntityCommand>(
await storeOutboxMessage<PublishEntityCommand>(
snapshot.id.toString(),
MediaServiceMessagingSettings.PublishEntity,
{
Expand All @@ -108,8 +113,8 @@ export const EntityListPublishingEndpointsPluginFactory = (
},
ctx,
{
metadata: {
authToken: await getLongLivedToken(jwtToken, config),
envelopeOverrides: {
auth_token: await getLongLivedToken(jwtToken, config),
},
},
);
Expand Down Expand Up @@ -140,7 +145,7 @@ export const EntityListPublishingEndpointsPluginFactory = (
resolveInfo: unknown,
) => {
try {
const { pgClient, jwtToken, config, storeInboxMessage } =
const { pgClient, jwtToken, config, storeOutboxMessage } =
getValidatedExtendedContext(context);
const snapshot = await selectOne('snapshots', {
entity_type: info.type,
Expand All @@ -154,7 +159,7 @@ export const EntityListPublishingEndpointsPluginFactory = (
});
}

await storeInboxMessage<UnpublishEntityCommand>(
await storeOutboxMessage<UnpublishEntityCommand>(
snapshot.id.toString(),
MediaServiceMessagingSettings.UnpublishEntity,
{
Expand All @@ -163,8 +168,8 @@ export const EntityListPublishingEndpointsPluginFactory = (
},
pgClient,
{
metadata: {
authToken: await getLongLivedToken(jwtToken, config),
envelopeOverrides: {
auth_token: await getLongLivedToken(jwtToken, config),
},
},
);
Expand Down Expand Up @@ -192,15 +197,15 @@ export const EntityListPublishingEndpointsPluginFactory = (
resolveInfo: unknown,
) => {
try {
const { jwtToken, config, pgClient, storeInboxMessage } =
const { jwtToken, config, pgClient, storeOutboxMessage } =
getValidatedExtendedContext(context);
const snapshot = await createListSnapshot(
info,
generateSnapshotJobId(),
pgClient,
);

await storeInboxMessage<PublishEntityCommand>(
await storeOutboxMessage<PublishEntityCommand>(
snapshot.id.toString(),
MediaServiceMessagingSettings.PublishEntity,
{
Expand All @@ -212,8 +217,8 @@ export const EntityListPublishingEndpointsPluginFactory = (
},
pgClient,
{
metadata: {
authToken: await getLongLivedToken(jwtToken, config),
envelopeOverrides: {
auth_token: await getLongLivedToken(jwtToken, config),
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { MosaicError } from '@axinom/mosaic-service-common';
import { Plugin } from 'graphile-build';
import { PgClass } from 'graphile-build-pg';
import { GraphileHelpers } from 'graphile-utils/node8plus/fieldHelpers';
import { GraphQLFieldConfig, GraphQLObjectType } from 'graphql';
import {
GraphQLFieldConfig,
GraphQLNonNull,
GraphQLNullableType,
} from 'graphql';
import { capitalize } from 'inflection';
import {
MediaServiceMessagingSettings,
Expand Down Expand Up @@ -45,17 +49,17 @@ export const EntityPublishingEndpointsPluginFactory = (
tableName: Table,
): Plugin => {
let table: PgClass;
let outType: GraphQLObjectType;
let outType: GraphQLNonNull<GraphQLNullableType>;

return (builder) => {
builder.hook('init', (input, build, _context) => {
table = findTable(build, tableName);

outType = getTableGqlType(build, 'snapshots');
if (build.getTypeByName(outType.name) === undefined) {
const nullableType = getTableGqlType(build, 'snapshots');
outType = new GraphQLNonNull(nullableType as GraphQLNullableType);
if (build.getTypeByName(nullableType.name) === undefined) {
build.newWithHooks(
build.graphql.GraphQLObjectType,
outType.toConfig(),
nullableType.toConfig(),
{},
);
}
Expand Down
Loading
Loading