Can you create records using GraphQL? - graphql

Does GraphQL have the capability of manipulating records (ie. POST/PUT/PATCH/DELETE)? If not, does GraphQL need to be coupled with a RESTful API to create/modify records?

Yes, they are called Mutations.
https://medium.com/#clayallsopp/your-first-graphql-server-3c766ab4f0a2 has one in its examples.

You got a great introduction to GraphQL and PostgreSQL in this youtube video: https://www.youtube.com/watch?v=DNPVqK_woRQ&list=PLmFRacg7hfyY7_bTCjdInHdpB2_H0j9s2
I learned a ton from it. In it, Lee shows how to setup a create mutation and relationships.
It also get a running GraphiQL setup to try queries in.

Related

How do you do CRUD in Gatsby with Sanity as my backend

I am now about knee-deep in a new Gatsby 4 project and may have hit a wall. I can't figure how to do CRUD in Gatsby with Sanity as my backend. Can I do GQL mutations in Gatsby GraphQL? I can't find any examples or tutorials anywhere.
I have done this in Next.js in a different project a but my backend was very different in my new project.
Any help is great.
I do not agree with #fstr's answer. All you can do in React can be done in Gatsby since it's a React-based framework.
if you mean using Gatsby data layer and by that the graphql portion of
it to apply a crud functionality in your site, then no. Gatsby's data
layer is a "one way street" it's designed to pull in data, if you want
to use mutations and/or subscriptions, you'll have to use something
like Apollo to handle the mutations aspects of the data.
This means that Gatsby fetches and gathers the data from the sources (like Strapi) when it builds the site (that's the one-way). The only thing you need to take into account is that because of Gatsby's staticity, you won't be able to create new pages on-demand (or on-the-fly) based on the user's input for example. If that's your scenario, you will need to trigger webhooks or to serve the site in the server, as Next and Gatsby v4 does.
If your use-case is, for example, display some database (or Strapi) fields, manipulate/mutate them based on some user's actions/inputs, and fetch them again to display them on the screen you can easily do using any Apollo implementation as this article, and many other, explains (Implementing CRUD in web application using React and GraphQL). In this case, you won't be taking many benefits of using Gatsby rather than any other CRA or React site, but it can be done either way.
So summarizing:
If you want to create dynamic pages based on some user's action, Gatsby won't help you much because you'll need to rebuild the site again, so it won't bypass the staticity.
If you want to mutate some data, send them back to the server, and display them again, it can be easily done.
If you mean modify your data stored in Sanity via Gatsby and then get Gatsby to show the updates in real-time (faster than rebuilding the whole site), this isn't something Gatsby will help you with as far as I know. Relevant:
https://github.com/gatsbyjs/gatsby/issues/22012
if you mean using Gatsby data layer and by that the graphql portion of it to apply a crud functionality in your site, then no. Gatsby's data layer is a "one way street" it's designed to pull in data, if you want to use mutations and/or subscriptions, you'll have to use something like Apollo to handle the mutations aspects of the data.
and
This is a good question! Gatsby data layer exists only during build time. After that, it is transformed into HTML and plain JSON files which you can deploy as a static site.
So at the moment if you want to use Apollo on the client, you need a separate GraphQL server.
Sanity does have an API you can use to modify data though:
https://www.sanity.io/docs/http-mutations

How to search GitHub Projects Beta with GraphQL API

I've been playing with Projects Beta using GitHub's GQL API but can't find a way to filter / search / query them.
For instance, I'd to get all issues in a project for which a field has a specific value.
How do I do so? Is it possible?
None of those objects as a filter attribute.
I've also looked at the search query but that doesn't seem to support Projects or Fields as query parmeters.
Thanks in advance!
I asked about this in the Projects Beta Feedback Discussion.
It seems that filtering hasn't been implemented (yet) and so it's necessary to do things the old fashioned way (like with the REST API) by using queries to get all the issues, then filtering after.
In many ways this is worse than things were with the REST API, as there's no way to get just the issues in a given column, you have to get every issue on the board, which quickly then gets you into needing pagination.
At least GraphQL queries are specifying which nodes/fields you want back, so you're not having to filter through all of everything, just some of everything.

Can I use DRF to recreate the ORO CRM API to get custom functionalities for my project

This might seem stupid but I've had this question for a long while. I've been using ORO CRM DB and its API for a while now. Its really one of the good open source CRMs. I just wanted to know if I can use their database and create a Django REST framework around it and create the same functionality of what ORO API is offering.
I would rather build the API with DRF than learn PHP to get the functionality that I need. So is this question. Kindly help me in figuring this out. Thanks in advance.
TL;DR
Yes for read, but using application database is a bad practice.
Explanation.
In Oro codebase there is a lot of triggers (listeners, queue message emitters) that could be fired during the CRUD operations, you can't use another code base to just mimic it.
Actually you can try to use DRF for read operation, that is rarely trigger any events, but doing this (use external db that is tend to change) is a bad practice.
You can try to explain your use case to get more context of what you are trying to achieve.

Laravel with Google BigQuery

I'm working on an application in which I want to use both Laravel and Google BigQuery to store the data.
I want to continue to use Laravel's Eloquent models for easily generating SQL, but I want all the SQL to be sent to Google BigQuery for storing and reading the data.
Is this possible with Laravel?
What is the best way to accomplish this?
Failing to find a library that is already handling this ( You would want something similar to Laravel Scout ) - You could Write a wrapper around the Google BigQuery Service ( with something like this https://github.com/schulzefelix/laravel-bigquery there is other packages available as well ) - With this you would then need to look at writing events off of the Laravel model you want to send to BigQuery https://laravel.com/docs/5.5/eloquent#events if you want to listen for many different events on a given model i would look into using Observers - https://laravel.com/docs/5.5/eloquent#observers
I would start with the above & have a look at https://github.com/laravel/scout for ideas on how you might be able to implement this.
I'm sure the OSS community would be very thankful if you where to package it up as well.
Good luck!

Elasticsearch search frontend demo

i'm searching for working search ui demo or tutorial for building search UI/Frontend. At best for php or js.
I never builded a elasticsearch application, but I already made projects with lucene, solr, epoq and google search.
Already searched on inet but most example are very simple and incomplete.
Examples:
github.com/scotchfield/elasticsearch-react-example/
github.com/spalger/elasticsearch-angular-example
There also API for PHP and JS
www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/quick-start.html
www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_quickstart.html
What a example should contain (from my view)
* Basic Search Field
* Filter based on es fields index
* Resultview
* Filter interaction with results
* Paging
I was thinking something like this is already exits, but found no matching one. I think better ask, before invest time in creating.
Thanks in Advance
densanki
I found this live demo interesting:
http://demo.searchkit.co/imdb
If you already know ElasticSearch query syntax and some basic concepts like aggregations you may test all that on https://demo.elastic.co/app/kibana. But again, this would require some basic knowledge of Elastic stack.
Otherwise if you want just touch/try most common Elasticsearch features without going into implementations details then you may check these 3 demos for 3rd party SearchKit UI component.
There's also Elastic UI that you might be interested in: https://elastic.github.io/eui/#/
If you want something ready-made for the time-series use-case, you might want to check Sematext Cloud. There's a simpler UI than Kibana there, but there's API access, too, so you can develop your own.

Resources