Skip to content

Commit

Permalink
Renamed response types to use data instead
Browse files Browse the repository at this point in the history
  • Loading branch information
maneesht committed Sep 19, 2024
1 parent 34eb062 commit c2a2d63
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ directive @auth(
"""
expr: Boolean_Expr @fdc_oneOf(required: true)
) on QUERY | MUTATION

"""
Marks an element of a GraphQL operation as no longer supported on the client.
The Firebase Data Connect backend will still support this element, but it will
no longer appear in generated SDKs.
"""
directive @retired(
"Explains why this element was retired."
reason: String
) on QUERY | MUTATION | FIELD | VARIABLE_DEFINITION

"Query filter criteria for `String` scalar fields."
input String_Filter {
"When true, match if field `IS NULL`. When false, match if field is `NOT NULL`."
Expand Down Expand Up @@ -304,6 +315,7 @@ input Any_ListFilter {
"Match if list field does not contain any of the provided values as members."
excludesAll: [Any!]
}

"""
(Internal) A string that uniquely identifies a type, field, and so on.
Expand Down Expand Up @@ -358,53 +370,7 @@ directive @fdc_generated(
| ENUM_VALUE
| INPUT_OBJECT
| INPUT_FIELD_DEFINITION
"""
Defines a database index to optimize query performance.
Given `type TableName @table @index(fields: [“fieldName”, “secondFieldName”])`,
`table_name_field_name_second_field_name_aa_idx` is the SQL index id.
`table_name_field_name_second_field_name_ad_idx` if `order: [ASC DESC]`.
`table_name_field_name_second_field_name_dd_idx` if `order: [DESC DESC]`.
Given `type TableName @table { fieldName: Int @index } `
`table_name_field_name_idx` is the SQL index id.
`order` matters less for single field indexes because they can be scanned in both ways.
Override with `@index(name)` in case of index name conflicts.
"""
directive @index(
"The SQL database index id. Defaults to <table_name>_<field_name>_idx."
name: String
"""
Only allowed and required when used on OBJECT.
The fields to create an index on.
"""
fields: [String!]
"""
Only allowed when used on OBJECT and BTREE index.
Index order of each column. Default to all ASC.
"""
order: [IndexFieldOrder!]
"""
For array field, default to `GIN`.
For Vector field, default to `HNSW`.
"""
type: IndexType
"""
Only allowed when used on vector field.
The vector similarity method. Default to `INNER_PRODUCT`.
"""
vector_method: VectorSimilarityMethod
) repeatable on FIELD_DEFINITION | OBJECT

enum IndexFieldOrder { ASC DESC }

enum IndexType {
BTREE
GIN
HNSW
IVFFLAT
}
type Query {
_service: _Service!
}
Expand All @@ -415,7 +381,10 @@ type Mutation {
}

type _Service {
"Full Service Definition Language of the Frebase Data Connect Schema, including normalized schema, predefined and generated types."
sdl: String!
"Orignal Schema Sources in the service."
schema: String!
}

"(Internal) Added to things that may be removed from FDC and will soon be no longer usable in schema or operations."
Expand Down Expand Up @@ -465,6 +434,7 @@ directive @fdc_oneOf(
"If true, exactly one field / argument in the group must be specified."
required: Boolean! = false
) repeatable on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION

"""
UUID is a string with hex digits representing an RFC4122 value.
Expand All @@ -490,16 +460,7 @@ scalar True
@fdc_forbiddenAsFieldType
@fdc_forbiddenAsVariableType
@fdc_example(value: true, description: "The only allowed value.")
"Define the intervals used in timestamps and dates (subset)"
enum TimestampInterval @fdc_deprecated {
second
minute
hour
day
week
month
year
}

"""
A Common Expression Language (CEL) expression that returns a boolean at runtime.
Expand Down Expand Up @@ -566,6 +527,7 @@ scalar Any_SQL
@fdc_sqlExpression
@fdc_forbiddenAsVariableType
@fdc_forbiddenAsFieldType

"""
Defines a relational database table.
Expand Down Expand Up @@ -718,24 +680,6 @@ enum OrderDirection {
DESC
}

enum ColDefault @fdc_deprecated {
"""
Generates a random UUID (v4) as the default column value.
Compatible with String or UUID typed fields.
"""
UUID
"""
Generates an auto-incrementing sequence as the default column value.
Compatible with Int and Int64 typed fields.
"""
SEQUENCE
"""
Populates the default column value with the current date or timestamp.
Compatible with Date and Timestamp typed fields.
"""
NOW
}

"""
Specify the default column value.
Expand All @@ -744,8 +688,6 @@ The supported arguments vary based on the field type.
directive @default(
"A constant value. Validated against the field GraphQL type at compile-time."
value: Any @fdc_oneOf(required: true)
"(Deprecated) Built-in common ways to generate initial value."
generate: ColDefault @fdc_oneOf(required: true) @deprecated
"A CEL expression, whose return value must match the field data type."
expr: Any_Expr @fdc_oneOf(required: true)
"""
Expand All @@ -757,6 +699,75 @@ directive @default(
"""
sql: Any_SQL @fdc_oneOf(required: true)
) on FIELD_DEFINITION

"""
Defines a database index to optimize query performance.
Given `type TableName @table @index(fields: [“fieldName”, “secondFieldName”])`,
`table_name_field_name_second_field_name_aa_idx` is the SQL index id.
`table_name_field_name_second_field_name_ad_idx` if `order: [ASC DESC]`.
`table_name_field_name_second_field_name_dd_idx` if `order: [DESC DESC]`.
Given `type TableName @table { fieldName: Int @index } `
`table_name_field_name_idx` is the SQL index id.
`order` matters less for single field indexes because they can be scanned in both ways.
Override with `@index(name)` in case of index name conflicts.
"""
directive @index(
"The SQL database index id. Defaults to <table_name>_<field_name>_idx."
name: String
"""
Only allowed and required when used on OBJECT.
The fields to create an index on.
"""
fields: [String!]
"""
Only allowed when used on OBJECT and BTREE index.
Index order of each column. Default to all ASC.
"""
order: [IndexFieldOrder!]
"""
For array field, default to `GIN`.
For Vector field, default to `HNSW`.
"""
type: IndexType
"""
Only allowed when used on vector field.
The vector similarity method. Default to `INNER_PRODUCT`.
"""
vector_method: VectorSimilarityMethod
) repeatable on FIELD_DEFINITION | OBJECT

enum IndexFieldOrder { ASC DESC }

enum IndexType {
BTREE
GIN
HNSW
IVFFLAT
}

"""
Defines a unique constraint.
Given `type TableName @table @unique(fields: [“fieldName”, “secondFieldName”])`,
`table_name_field_name_second_field_name_uidx` is the SQL unique index id.
Given `type TableName @table { fieldName: Int @unique } `
`table_name_field_name_uidx` is the SQL unique index id.
Override with `@unique(indexName)` in case of index name conflicts.
"""
directive @unique(
"The SQL database unique index name. Defaults to <table_name>_<field_name>_uidx."
indexName: String
"""
Only allowed and required when used on OBJECT.
The fields to create a unique constraint on.
"""
fields: [String!]
) repeatable on FIELD_DEFINITION | OBJECT

"""
Date is a string in the YYYY-MM-DD format representing a local-only date.
Expand Down Expand Up @@ -980,25 +991,7 @@ enum Date_Interval @fdc_forbiddenAsFieldType {
MONTH
YEAR
}
"""
Defines a unique constraint.
Given `type TableName @table @unique(fields: [“fieldName”, “secondFieldName”])`,
`table_name_field_name_second_field_name_uidx` is the SQL unique index id.
Given `type TableName @table { fieldName: Int @unique } `
`table_name_field_name_uidx` is the SQL unique index id.

Override with `@unique(indexName)` in case of index name conflicts.
"""
directive @unique(
"The SQL database unique index name. Defaults to <table_name>_<field_name>_uidx."
indexName: String
"""
Only allowed and required when used on OBJECT.
The fields to create a unique constraint on.
"""
fields: [String!]
) repeatable on FIELD_DEFINITION | OBJECT
"Update input of a String value"
input String_Update {
set: String @fdc_oneOf(group: "set")
Expand Down Expand Up @@ -1090,6 +1083,7 @@ input Any_ListUpdate {
append: [Any!]
prepend: [Any!]
}

"""
Vector is an array of single-precision floating-point numbers, serialized
as a JSON array. All elements must be finite (no NaN, Infinity or -Infinity).
Expand Down Expand Up @@ -1168,3 +1162,4 @@ scalar Vector_Embed_Model
@fdc_forbiddenAsVariableType
@fdc_forbiddenAsFieldType
@fdc_example(value: "textembedding-gecko@003", description: "A stable version of the textembedding-gecko model")

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ mutation addDirectorToMovie($personId: Person_Key, $movieId: UUID)
@auth(level: PUBLIC) {
directedBy_insert(data: { directedby: $personId, movieId: $movieId })
}
mutation seedData @auth(level: PUBLIC) {
movies1: 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."
}
)
}
mutation createMovie(
$title: String!
$releaseYear: Int!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ class AddDirectorToMovie {
String name = "addDirectorToMovie";
AddDirectorToMovie({required this.dataConnect});

Deserializer<AddDirectorToMovieResponse> dataDeserializer = (String json) =>
AddDirectorToMovieResponse.fromJson(
jsonDecode(json) as Map<String, dynamic>);
Deserializer<AddDirectorToMovieData> dataDeserializer = (String json) =>
AddDirectorToMovieData.fromJson(jsonDecode(json) as Map<String, dynamic>);
Serializer<AddDirectorToMovieVariables> varsSerializer =
(AddDirectorToMovieVariables vars) => jsonEncode(vars.toJson());
MutationRef<AddDirectorToMovieResponse, AddDirectorToMovieVariables> ref(
{AddDirectorToMovieVariablesPersonId? personId,
String? movieId,
AddDirectorToMovieVariables? addDirectorToMovieVariables}) {
AddDirectorToMovieVariables vars1 = AddDirectorToMovieVariables(
MutationRef<AddDirectorToMovieData, AddDirectorToMovieVariables> ref({
AddDirectorToMovieVariablesPersonId? personId,
String? movieId,
}) {
AddDirectorToMovieVariables vars = AddDirectorToMovieVariables(
personId: personId,
movieId: movieId,
);
AddDirectorToMovieVariables vars = addDirectorToMovieVariables ?? vars1;

return dataConnect.mutation(
this.name, dataDeserializer, varsSerializer, vars);
}
Expand Down Expand Up @@ -53,10 +52,10 @@ class AddDirectorToMovieDirectedByInsert {
}
}

class AddDirectorToMovieResponse {
class AddDirectorToMovieData {
late AddDirectorToMovieDirectedByInsert directedBy_insert;

AddDirectorToMovieResponse.fromJson(Map<String, dynamic> json)
AddDirectorToMovieData.fromJson(Map<String, dynamic> json)
: directedBy_insert = AddDirectorToMovieDirectedByInsert.fromJson(
json['directedBy_insert']) {}

Expand All @@ -69,7 +68,7 @@ class AddDirectorToMovieResponse {
return json;
}

AddDirectorToMovieResponse({
AddDirectorToMovieData({
required this.directedBy_insert,
}) {
// TODO(mtewani): Only show this if there are optional fields.
Expand Down Expand Up @@ -124,8 +123,8 @@ class AddDirectorToMovieVariables {
}

AddDirectorToMovieVariables({
AddDirectorToMovieVariablesPersonId? this.personId,
String? this.movieId,
this.personId,
this.movieId,
}) {
// TODO(mtewani): Only show this if there are optional fields.
}
Expand Down
Loading

0 comments on commit c2a2d63

Please sign in to comment.