Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mtewani/fix-nativetojson
Browse files Browse the repository at this point in the history
  • Loading branch information
maneesht committed Sep 26, 2024
2 parents adaf0e5 + b2500a9 commit fc857b9
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ mutation deleteMovie($id: UUID!) @auth(level: PUBLIC) {
movie_delete(id: $id)
}

mutation thing($title: Any! = "ABC") @auth(level: PUBLIC) {
thing_insert(data: {
title: $title
})
}

mutation seedData @auth(level: PUBLIC) {
the_matrix: movie_insert(
data: {
title: "The Matrix"
releaseYear: 1999
genre: "Action"
rating: 5.0
description: "When a beautiful stranger leads computer hacker Neo to a forbidding underworld, he discovers the shocking truth--the life he knows is the elaborate deception of an evil cyber-intelligence."
}
)
}

# # Update movie information based on the provided ID
# mutation updateMovie(
# $id: UUID!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ query ListPersons @auth(level: USER) {
name
}
}
query ListThing($data: Any) @auth(level: USER) {
things(where: {
title: {
eq: $data
}
}) {
title
}
}

query ListTimestamps @auth(level: USER) {
timestampHolders {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type Movie @table {
releaseYear: Int
rating: Float
}
type Thing @table {
title: Any!
}
type TimestampHolder @table {
timestamp: Timestamp!
date: Date
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
part of movies;

class ListThing {
String name = "ListThing";
ListThing({required this.dataConnect});

Deserializer<ListThingData> dataDeserializer = (String json) =>
ListThingData.fromJson(jsonDecode(json) as Map<String, dynamic>);
Serializer<ListThingVariables> varsSerializer =
(ListThingVariables vars) => jsonEncode(vars.toJson());
QueryRef<ListThingData, ListThingVariables> ref({
dynamic? data,
}) {
ListThingVariables vars = ListThingVariables(
data: AnyValue(data),
);

return dataConnect.query(this.name, dataDeserializer, varsSerializer, vars);
}

FirebaseDataConnect dataConnect;
}

class ListThingThings {
AnyValue title;

ListThingThings.fromJson(Map<String, dynamic> json)
: title = AnyValue.fromJson(json['title']) {}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

json['title'] = title.toJson();

return json;
}

ListThingThings({
required this.title,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}

class ListThingData {
List<ListThingThings> things;

ListThingData.fromJson(Map<String, dynamic> json)
: things = (json['things'] as List<dynamic>)
.map((e) => ListThingThings.fromJson(e))
.toList() {}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

json['things'] = things.map((e) => e.toJson()).toList();

return json;
}

ListThingData({
required this.things,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}

class ListThingVariables {
AnyValue? data;

ListThingVariables.fromJson(Map<String, dynamic> json) {
data = json['data'] == null ? null : AnyValue.fromJson(json['data']);
}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

if (data != null) {
json['data'] = data!.toJson();
}

return json;
}

ListThingVariables({
this.data,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ library movies;
import 'package:firebase_data_connect/firebase_data_connect.dart';
import 'dart:convert';

part 'list_movies.dart';

part 'list_movies_by_partial_title.dart';

part 'list_persons.dart';

part 'list_thing.dart';

part 'add_person.dart';

part 'add_director_to_movie.dart';
Expand All @@ -17,15 +25,29 @@ part 'create_movie.dart';

part 'delete_movie.dart';

part 'list_movies.dart';
part 'thing.dart';

part 'list_movies_by_partial_title.dart';

part 'list_persons.dart';
part 'seed_data.dart';

part 'list_timestamps.dart';

class MoviesConnector {
ListMovies get listMovies {
return ListMovies(dataConnect: dataConnect);
}

ListMoviesByPartialTitle get listMoviesByPartialTitle {
return ListMoviesByPartialTitle(dataConnect: dataConnect);
}

ListPersons get listPersons {
return ListPersons(dataConnect: dataConnect);
}

ListThing get listThing {
return ListThing(dataConnect: dataConnect);
}

AddPerson get addPerson {
return AddPerson(dataConnect: dataConnect);
}
Expand Down Expand Up @@ -54,16 +76,12 @@ class MoviesConnector {
return DeleteMovie(dataConnect: dataConnect);
}

ListMovies get listMovies {
return ListMovies(dataConnect: dataConnect);
}

ListMoviesByPartialTitle get listMoviesByPartialTitle {
return ListMoviesByPartialTitle(dataConnect: dataConnect);
Thing get thing {
return Thing(dataConnect: dataConnect);
}

ListPersons get listPersons {
return ListPersons(dataConnect: dataConnect);
SeedData get seedData {
return SeedData(dataConnect: dataConnect);
}

ListTimestamps get listTimestamps {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
part of movies;

class SeedData {
String name = "seedData";
SeedData({required this.dataConnect});

Deserializer<SeedDataData> dataDeserializer = (String json) =>
SeedDataData.fromJson(jsonDecode(json) as Map<String, dynamic>);

MutationRef<SeedDataData, void> ref() {
return dataConnect.mutation(
this.name, dataDeserializer, emptySerializer, null);
}

FirebaseDataConnect dataConnect;
}

class SeedDataTheMatrix {
String id;

SeedDataTheMatrix.fromJson(Map<String, dynamic> json)
: id = nativeFromJson<String>(json['id']) {}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

json['id'] = nativeToJson<String>(id);

return json;
}

SeedDataTheMatrix({
required this.id,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}

class SeedDataData {
SeedDataTheMatrix the_matrix;

SeedDataData.fromJson(Map<String, dynamic> json)
: the_matrix = SeedDataTheMatrix.fromJson(json['the_matrix']) {}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

json['the_matrix'] = the_matrix.toJson();

return json;
}

SeedDataData({
required this.the_matrix,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
part of movies;

class Thing {
String name = "thing";
Thing({required this.dataConnect});

Deserializer<ThingData> dataDeserializer = (String json) =>
ThingData.fromJson(jsonDecode(json) as Map<String, dynamic>);
Serializer<ThingVariables> varsSerializer =
(ThingVariables vars) => jsonEncode(vars.toJson());
MutationRef<ThingData, ThingVariables> ref({
dynamic title,
}) {
ThingVariables vars = ThingVariables(
title: AnyValue(title),
);

return dataConnect.mutation(
this.name, dataDeserializer, varsSerializer, vars);
}

FirebaseDataConnect dataConnect;
}

class ThingThingInsert {
String id;

ThingThingInsert.fromJson(Map<String, dynamic> json)
: id = nativeFromJson<String>(json['id']) {}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

json['id'] = nativeToJson<String>(id);

return json;
}

ThingThingInsert({
required this.id,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}

class ThingData {
ThingThingInsert thing_insert;

ThingData.fromJson(Map<String, dynamic> json)
: thing_insert = ThingThingInsert.fromJson(json['thing_insert']) {}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

json['thing_insert'] = thing_insert.toJson();

return json;
}

ThingData({
required this.thing_insert,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
}

class ThingVariables {
Optional<AnyValue> _title =
Optional.optional(AnyValue.fromJson, defaultSerializer);

set title(AnyValue t) {
this._title.value = t;
}

AnyValue get title => this._title.value!;

ThingVariables.fromJson(Map<String, dynamic> json) {
_title.value =
json['title'] == null ? null : AnyValue.fromJson(json['title']);
}

Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};

if (_title.state == OptionalState.set) {
json['title'] = _title.toJson();
}

return json;
}

ThingVariables({
AnyValue? title,
}) {
// TODO(mtewani): Only show this if there are optional fields.

this._title = Optional.optional(AnyValue.fromJson, defaultSerializer);
this._title.value = title;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash
firebase emulators:start --project flutterfire-e2e-tests &
sleep 30
# firebase emulators:start --project flutterfire-e2e-tests &
# Added below to fix the e2e tests
npx "firebase/firebase-tools#mtewani/dart-bugbash" emulators:start --project flutterfire-e2e-tests &
sleep 45
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ part 'src/core/ref.dart';
part 'src/firebase_data_connect.dart';
part 'src/optional.dart';
part 'src/timestamp.dart';
part 'src/any_value.dart';
Loading

0 comments on commit fc857b9

Please sign in to comment.