Skip to content

Commit 9972471

Browse files
committed
fix: naming conventions
1 parent c470c4c commit 9972471

3 files changed

Lines changed: 38 additions & 58 deletions

File tree

dataconnect/app/src/pages/Movie.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ export default function MoviePage() {
4848
}, [id, auth]);
4949

5050
useEffect(() => {
51+
async function fetchSimilarMovies(description: string) {
52+
try {
53+
const response = await searchMovieDescriptionUsingL2similarity({ query: description });
54+
setSimilarMovies(response?.data?.movies_descriptionEmbedding_similarity);
55+
} catch (error) {
56+
console.error('Error fetching similar movies:', error);
57+
}
58+
}
5159
if (id) {
5260
const fetchMovie = async () => {
5361
try {
@@ -67,15 +75,6 @@ export default function MoviePage() {
6775
}
6876
}, [id, authUser]);
6977

70-
async function fetchSimilarMovies(description: string) {
71-
try {
72-
const response = await searchMovieDescriptionUsingL2similarity({ query: description });
73-
setSimilarMovies(response?.data?.movies_descriptionEmbedding_similarity);
74-
} catch (error) {
75-
console.error('Error fetching similar movies:', error);
76-
}
77-
}
78-
7978
async function handleFavoriteToggle(e: React.MouseEvent) {
8079
e.stopPropagation();
8180
e.preventDefault();

dataconnect/dataconnect/movie-connector/mutations.gql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Create a movie based on user input
2-
mutation createMovie(
2+
mutation CreateMovie(
33
$title: String!
44
$releaseYear: Int!
55
$genre: String!
@@ -22,7 +22,7 @@ mutation createMovie(
2222
}
2323

2424
# Update movie information based on the provided ID
25-
mutation updateMovie(
25+
mutation UpdateMovie(
2626
$id: UUID!
2727
$title: String
2828
$releaseYear: Int
@@ -47,37 +47,37 @@ mutation updateMovie(
4747
}
4848

4949
# Delete a movie by its ID
50-
mutation deleteMovie($id: UUID!) @auth(level: USER_EMAIL_VERIFIED) {
50+
mutation DeleteMovie($id: UUID!) @auth(level: USER_EMAIL_VERIFIED) {
5151
movie_delete(id: $id)
5252
}
5353

5454
# Delete movies with a rating lower than the specified minimum rating
55-
mutation deleteUnpopularMovies($minRating: Float!) @auth(level: USER_EMAIL_VERIFIED) {
55+
mutation DeleteUnpopularMovies($minRating: Float!) @auth(level: USER_EMAIL_VERIFIED) {
5656
movie_deleteMany(where: { rating: { le: $minRating } })
5757
}
5858

5959
# Add a movie to the user's favorites list
60-
mutation addFavoritedMovie($movieId: UUID!) @auth(level: USER) {
60+
mutation AddFavoritedMovie($movieId: UUID!) @auth(level: USER) {
6161
favorite_movie_upsert(data: { userId_expr: "auth.uid", movieId: $movieId })
6262
}
6363

6464
# Remove a movie from the user's favorites list
65-
mutation deleteFavoritedMovie($movieId: UUID!) @auth(level: USER) {
65+
mutation DeleteFavoritedMovie($movieId: UUID!) @auth(level: USER) {
6666
favorite_movie_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
6767
}
6868

6969
# Add an actor to the user's favorites list
70-
mutation addFavoritedActor($actorId: UUID!) @auth(level: USER) {
70+
mutation AddFavoritedActor($actorId: UUID!) @auth(level: USER) {
7171
favorite_actor_upsert(data: { userId_expr: "auth.uid", actorId: $actorId })
7272
}
7373

7474
# Remove an actor from the user's favorites list
75-
mutation deleteFavoriteActor($actorId: UUID!) @auth(level: USER) {
75+
mutation DeleteFavoritedActor($actorId: UUID!) @auth(level: USER) {
7676
favorite_actor_delete(key: { userId_expr: "auth.uid", actorId: $actorId })
7777
}
7878

7979
# Add a review for a movie
80-
mutation addReview(
80+
mutation AddReview(
8181
$movieId: UUID!
8282
$rating: Int!
8383
$reviewText: String!
@@ -94,14 +94,14 @@ mutation addReview(
9494
}
9595

9696
# Delete a user's review for a movie
97-
mutation deleteReview(
97+
mutation DeleteReview(
9898
$movieId: UUID!
9999
) @auth(level: USER) {
100100
review_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
101101
}
102102

103103
# Upsert (update or insert) a user based on their username
104-
mutation upsertUser($username: String!) @auth(level: USER) {
104+
mutation UpsertUser($username: String!) @auth(level: USER) {
105105
user_upsert(
106106
data: {
107107
id_expr: "auth.uid"

dataconnect/dataconnect/movie-connector/queries.gql

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ query GetIfFavoritedActor($actorId: UUID!) @auth(level: USER) {
278278
}
279279

280280
# Search for movies, actors, and reviews
281-
query searchAll(
281+
query SearchAll(
282282
$input: String
283283
$minYear: Int!
284284
$maxYear: Int!
@@ -343,41 +343,22 @@ query searchAll(
343343
}
344344
}
345345

346-
# Search movie descriptions using L2 similarity with Vertex AI
347-
query searchMovieDescriptionUsingL2Similarity($query: String!)
348-
@auth(level: PUBLIC) {
349-
movies_descriptionEmbedding_similarity(
350-
compare_embed: { model: "textembedding-gecko@003", text: $query }
351-
method: L2
352-
within: 2
353-
where: { isNull: false }
354-
limit: 5
355-
) {
356-
id
357-
title
358-
description
359-
tags
360-
rating
361-
imageUrl
362-
}
363-
}
346+
# # Search movie descriptions using L2 similarity with Vertex AI
347+
# query SearchMovieDescriptionUsingL2Similarity($query: String!)
348+
# @auth(level: PUBLIC) {
349+
# movies_descriptionEmbedding_similarity(
350+
# compare_embed: { model: "textembedding-gecko@003", text: $query }
351+
# method: L2
352+
# within: 2
353+
# where: { isNull: false }
354+
# limit: 5
355+
# ) {
356+
# id
357+
# title
358+
# description
359+
# tags
360+
# rating
361+
# imageUrl
362+
# }
363+
# }
364364

365-
# Search movie descriptions using L2 similarity with Vertex AI, with custom embeddings
366-
query searchMovieDescriptionUsingL2Similarity1(
367-
$compare: Vector!
368-
$within: Float
369-
$excludesContent: String
370-
$limit: Int
371-
) @auth(level: PUBLIC) {
372-
movies_descriptionEmbedding_similarity(
373-
compare: $compare
374-
method: L2
375-
within: $within
376-
where: { description: { ne: $excludesContent } }
377-
limit: $limit
378-
) {
379-
id
380-
title
381-
description
382-
}
383-
}

0 commit comments

Comments
 (0)