configuration makefile and dataconnect init

This commit is contained in:
José Salazar
2025-11-15 18:51:28 -05:00
committed by bwnyasse
parent ed6e51a29e
commit 6e247867e1
26 changed files with 4357 additions and 21 deletions

View File

@@ -0,0 +1,8 @@
connectorId: example
generate:
javascriptSdk:
- outputDir: ../../frontend-web/src/dataconnect-generated
package: "@dataconnect/generated"
packageJsonDir: ../../frontend-web
react: true
angular: false

View File

@@ -0,0 +1,33 @@
# Example mutations for a simple movie app
# Create a movie based on user input
mutation CreateMovie($title: String!, $genre: String!, $imageUrl: String!)
@auth(level: USER_EMAIL_VERIFIED, insecureReason: "Any email verified users can create a new movie.") {
movie_insert(data: { title: $title, genre: $genre, imageUrl: $imageUrl })
}
# Upsert (update or insert) a user's username based on their auth.uid
mutation UpsertUser($username: String!) @auth(level: USER) {
# The "auth.uid" server value ensures that users can only register their own user.
user_upsert(data: { id_expr: "auth.uid", username: $username })
}
# Add a review for a movie
mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!)
@auth(level: USER) {
review_upsert(
data: {
userId_expr: "auth.uid"
movieId: $movieId
rating: $rating
reviewText: $reviewText
# reviewDate defaults to today in the schema. No need to set it manually.
}
)
}
# Logged in user can delete their review for a movie
mutation DeleteReview($movieId: UUID!) @auth(level: USER) {
# The "auth.uid" server value ensures that users can only delete their own reviews.
review_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
}

View File

@@ -0,0 +1,78 @@
# Example queries for a simple movie app.
# @auth() directives control who can call each operation.
# Anyone should be able to list all movies, so the auth level is set to PUBLIC
query ListMovies @auth(level: PUBLIC, insecureReason: "Anyone can list all movies.") {
movies {
id
title
imageUrl
genre
}
}
# List all users, only admins should be able to list all users, so we use NO_ACCESS
query ListUsers @auth(level: NO_ACCESS) {
users {
id
username
}
}
# Logged in users can list all their reviews and movie titles associated with the review
# Since the query uses the uid of the current authenticated user, we set auth level to USER
query ListUserReviews @auth(level: USER) {
user(key: { id_expr: "auth.uid" }) {
id
username
# <field>_on_<foreign_key_field> makes it easy to grab info from another table
# Here, we use it to grab all the reviews written by the user.
reviews: reviews_on_user {
rating
reviewDate
reviewText
movie {
id
title
}
}
}
}
# Get movie by id
query GetMovieById($id: UUID!) @auth(level: PUBLIC, insecureReason: "Anyone can get a movie by id.") {
movie(id: $id) {
id
title
imageUrl
genre
metadata: movieMetadata_on_movie {
rating
releaseYear
description
}
reviews: reviews_on_movie {
reviewText
reviewDate
rating
user {
id
username
}
}
}
}
# Search for movies, actors, and reviews
query SearchMovie($titleInput: String, $genre: String) @auth(level: PUBLIC, insecureReason: "Anyone can search for movies.") {
movies(
where: {
_and: [{ genre: { eq: $genre } }, { title: { contains: $titleInput } }]
}
) {
id
title
genre
imageUrl
}
}