How can I access a google cloud datastore using graphql? - google-cloud-datastore

As of now we are using gstore to query the google cloud datastore, but we're looking to migrate from REST to GraphQL. The problem is I can't find any resources online on how to access the data on the google cloud datastore using GraphQL. I've got GraphQL working with local json files but haven't been able to make it query from the datastore.

It looks like graphql-genie supports GraphQL on Cloud Datastore. If that doesn't work for you, should should be able to adapt the Firestore with GraphQL code.

Related

How to export data from Firebase Firestore emulator to actual Firebase Firestore database

Scenario:
I am working on a POC locally where I am using Firestore as my database. As it is my local setup I am using Firestore Emulator. Now my POC is successful and I want to move local database from emulator to actual Firestore.
Query:
Is it possible to achieve what I am trying to do?
So far I am not able to find any relevant content on internet around this. I did find couple of examples where there is demonstration of exporting data from Firestore and importing to local emulator but I was not able to find the vice-versa option!
Firebase does not provide any sort of tool or service to do this. Your easiest alternative will be to write a program to query the data out of the emulator and write it into your cloud hosted instance. You might find the Firebase Admin SDK helpful for writing to the cloud in a program that you run locally.

Postman API to connect to Firebase Realtime DB

I am confused as to how to connect to my Firebase DB using, say Postman to send the REST requests.
In the screenshot below, you can see my DB structure and GET request.
Specifically, the GET request in Postman looks like this,
https://fir-crud-api-b1cec.firebaseio.com/products/test.json?auth=xxxx
while the DB is structured as such
products > test.json
Would appreciate any advice to point me in the right direction. Thanks!
Your URL suggests that you want to use the Realtime Datbase REST API, but your screenshot suggests that your data is in Firestore. These are different databases with different APIs.
If you want to work with data in Firestore, you should use the Firestore REST API instead.
The screenshot on the left shows the Cloud Firestore database, while in PostMan you are trying to access the Realtime Database. While both databases are part of Firebase, they're completely separate, and have completely separate REST APIs.
If you want to access Cloud Firestore from PostMan, have a look at its REST API. Fair warning that this API is significantly more complex than the one for the Realtime Database.
If you want to continue using the Realtime Database REST API, make sure to create your data structure in the Realtime Database in the Firebase console.

Is there any way to get realtime updates from Firebase Firestore REST API?

I have a chip that has internet connectivity that I am programming using C language. I am able to make http requests using this language, so I thought that the Firestore REST API would save me. Unfortunately, I can't figure out a way to get live changes from the REST API. Any ideas?
firebaser here
There is currently no public API to get realtime updates from Firestore over its REST API. See the reference docs for a list of available operations.
Also see:
Firestore REST API database listening, which mentions that you can get this behavior through the RPC API.

How can I use Firebase to query an external API and store data in Firestore?

I'm teaching myself to use Flutter and I'm making an app that queries The Movie Database API. Currently, I'm having the client query the API on launch but I'm thinking this is not the most efficient way of doing it, and I would rather have the client query a backend service like Firebase to get the same data.
I would appreciate some guidance into where to start in order to setup a periodical process to query the API and use the results as entries into a Firestore DB. I've looked online but I might be using suboptimal keywords since I haven't found a good tutorial or example for this.
Thanks.
You can use Firebase Cloud Functions to build code that runs on Firebase servers to fill your Firebase database, but you can only make HTTP requests to non-Google addresses if you use a paid plan.
https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html explains how to invoke periodic tasks with Cloud Functions. It utilizes Google AppEngine for that because Cloud Functions doesn't provide that out of the box.

How to switch from Datastore to Firestore in existing project?

I have an existing Google Cloud project which uses Datastore. I'm excited by Firestore and would like to switch. According to https://www.youtube.com/watch?v=SYG-BgXoJFQ it is recommended to create a new project.
Is it possible to just nuke Datastore somehow (I don't care about the data) and start from scratch with Firestore?
If not, what are the implications of creating a new project?
If there is no data written to Cloud datastore, it's possible to convert from datastore to firestore with the following steps. I tried on 2 projects and each project took 3 minutes. The user should be the project owner to attempt:
Disable Cloud datastore API
Disable Cloud Firestore API
gcloud firestore databases create --region=us-central --project $PROJECT_ID
I have another project that has little datastore entities. I deleted them and executed the steps, but received the following error. While disabling datastore API, I read Disable Cloud Datastore API? If any resources were created by Cloud Datastore API, they may be deleted soon after Cloud Datastore API is disabled. All code that uses this project's credentials to call Cloud Datastore API will fail.
ERROR: (gcloud.firestore.databases.create) Error Response: [9] The
"database_type" field cannot be modified for this application. Note:
If data has already been written for this application, then the
"database_type" may not be modified.
The solution is to contact Google cloud support to convert from Datastore to Firestore. You need to make sure no entities exist and nothing is creating any entities.
In the case where no Datastore entities have been written, the operation should succeed:
Success! Selected Google Cloud Firestore Native database for $PROJECT_ID
It is not possible to switch from Datastore to Firestore within the same project as yet, but you may operate Firestore in Datastore mode. By creating a Cloud Firestore database in Datastore mode, you can access Cloud Firestore's improved storage layer while keeping Cloud Datastore system behavior. You may find more information of relevance by reading the "Automatic Upgrade to Cloud Firestore" documentation page.

Resources