Flutter: GraphQLError: invalid input syntax for type uuid: "" - firebase

I am new to GraphQL and Hasura. I am acquiring a firebase user JWT and passing it to a Hasura GraphQL endpoint, but I'm receiving error messages
GTMSessionFetcher invoking fetch callbacks, data {length = 3322, bytes = 0x7b0a2020 22616363 6573735f 746f6b65 ... 31303535 220a7d0a }, error (null)
flutter: OperationException(linkException: null, graphqlErrors: [GraphQLError(message: invalid input syntax for type uuid: "", locations: null, path: null, extensions: {path: $.selectionSet.insert_member_one.args.object, code: data-exception})])

You are getting this error because the URL passed in the initialization of graphql client is wrong or has special characters included. Try using
Uri.Parse('YOUR_URL_HERE)
in the GraphQLClient()

An empty string is 1: not null, if it's a nullable field, and 2: not a valid uuid (v4 at least, I ran into this same problem) use 00000000-0000-0000-0000-000000000000 as nil/empty uuid v4.
https://www.uuidgenerator.net/version-nil

Related

Issues with startAt in orderBy timestamp - Firebase REST API

Im using the Firebase REST API to retrieve data with the GET method, this is the URL im executing:
const url = `https://firestore.googleapis.com/v1/projects/${projectId}/databases/${dataBase}/documents/${collectionName}/${documentId}?&key=${apiKey}&pageSize=${pageSize}&pageToken=${nextPageToken}&orderBy=timestamp&startAt=${startTime}`;
But it return this error:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"startAt\": Cannot bind query parameter. Field 'startAt' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"startAt\": Cannot bind query parameter. Field 'startAt' could not be found in request message."
}
]
}
]
}
}
If im omitting the paramemeter of startAt it works fine.
The format of startTime, id try it in all the following ways, and all return the same error:
Firebase return format: 2022-06-16T15:46:46.061Z
Unix Timestamp:1655394406
ISO 8601 date: 2022-06-16T15:46:46+00:00
What im doing wrong?
(For reference here is the official documentation where the startAt is explained)
You're calling the Firestore REST API, but are referencing the documentation for the REST API of the Realtime Database. While both products are part of Firebase, they are complete separate - and the API of one cannot be applied to the other.
For the documentation of the Firestore REST API, see https://firebase.google.com/docs/firestore/reference/rest

serverless step functions: Getting error when passing more than one fields in the payload for lambda

Error: Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The value for the field 'Date.$' must be a valid JSONPath at /States/Insert Data Dynamodb/Parameters' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition;
below is the corresponding serverless.yaml code.
I tried wrapping the two parameters into encoded json string and passed it as single payload field and it resulted in the same error but when there is only one plain field in the payload this code deployed successfully
Any suggestions on how to pass two parameters?
service: service-name
frameworkVersion: '2'
provider:
name: aws
runtime: go1.x
lambdaHashingVersion: 20201221
stage: ${opt:stage, self:custom.defaultStage}
region: us-east-1
tags: ${self:custom.tagsObject}
logRetentionInDays: 1
timeout: 10
deploymentBucket: lambda-repository
memorySize: 128
tracing:
lambda: true
plugins:
- serverless-step-functions
configValidationMode: error
stepFunctions:
stateMachines:
sortData:
name: datasorting-dev
type: STANDARD
role: ${self:custom.datasorting.${self:provider.stage}.iam}
definition:
Comment: "Data Sort"
StartAt: Query Data
States:
Query Data:
Type: Task
Resource: arn:aws:states:::athena:startQueryExecution.sync
Parameters:
QueryString: >-
select * from table.data
WorkGroup: primary
ResultConfiguration:
OutputLocation: s3://output/location
Next: Insert Data Dynamodb
Insert Data Dynamodb:
Type: Task
Resource: arn:aws:states:::lambda:invoke
Parameters:
FunctionName: arn:aws:lambda:us-east-1:${account-id}:function:name
Payload:
OutputLocation.$: $.QueryExecution.ResultConfiguration.OutputLocation
Date.$: ${self:custom.dates.year}${self:custom.dates.month}${self:custom.dates.day}
End: true
Your Date.$ property has value of ${self:custom.dates.year}${self:custom.dates.month}${self:custom.dates.day}. Let's assume that:
const dates = {
"year": "2000",
"month": "01",
"day": "20"
}
The result will be Date.$: "20000120" which is not a valid JSON Path.
JSON Path needs to start with a $ sign and each level is divided by ..
Do you want to achieve something like this? $.2000.01.20?
As you see, the issue is not with passing 2 parameters but with wrong string JSON Path created by string interpolation for Date.$.
Some useful links:
https://github.com/json-path/JsonPath
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-paths.html

Firestore Error: [cloud_firestore/unknown] Invalid argument (dartObject): Could not convert: Instance of '_FieldValueServerTimestamp'

I'm using flutter and firestore and what I want to do is adding an object as a child inside a list, each time I hit a submit button. Inside that object, I want to have a createdAt field, where the timestamp information should be stored. For that, i'm trying to use FieldValue.serverTimestamp(), but i'm getting the following error.
Uncaught (in promise) Error: [cloud_firestore/unknown] Invalid argument (dartObject): Could not convert: Instance of '_FieldValueServerTimestamp'
The code is as below:
reference.update({
'parentData': FieldValue.arrayUnion([
{
'data': myData,
'createdAt': FieldValue.serverTimestamp()
}
]),
});
I'm also importing the library:
import 'package:cloud_firestore/cloud_firestore.dart';

Set or Add in Firebase which I need to use for creating a new Database entry?

I want to save User's name in a Database of Firebase called profiles
While I am using the below code it is not creating any entry in my database:
register() {
fb.auth().createUserWithEmailAndPassword(this.email, this.password)
.then((user)=>{
db.collection('profiles').doc(user.user.uid).set({
name: this.profile.name
})
}
I have a profile object. So, it is not a problem.
If I use add like the below, it is creating entry.
db.collection('profiles').add({
name: this.profile.name
})
But Problem is while I am trying to retrieve it's ID, it is not giving me the correct result.
db.collection("profiles").doc(user.uid).update({
name: this.profile.name,
mobile: this.profile.mobile,
postcode: this.profile.postcode
});
uid is not matching.
ERROR:
[Vue warn]: Error in v-on handler: "FirebaseError: [code=invalid-argument]: Function DocumentReference.update() called with invalid data. Unsupported field value: undefined (found in field name)"

Error while editing existing GSI on my scheme

I am using AppSync with DynamoDB and GraphQL API. My current scheme works as expected but when trying to edit existing GSI I am getting an error.
My current scheme looks like this:
type Item #model
#key(fields: ["id", "version"])
#key(name: "type-subtype", fields: ["type", "subtype"])
{
id: ID!
version: String!
type: String!
subtype: String!
}
I want to change GSI defined here to be:
#key(name: "version-type-subtype", fields: ["version", "type", "subtype"]
The error I am getting is Schema Creation Status is FAILED with details: Failed to parse schema document - ensure it's a valid SDL-formatted document.
Can someone help? Is there any constraint using sort key from primary index as hash in GSI that I am not aware of?
Thanks

Resources