Should I use drupal's graphql module? - drupal

I'm building a website with drupal as a CMS and going to integrate Graphql as a middleware. I've seen a lot of examples using the drupal's integrated graphql module, but I feel like it goes against the purpose of having a single decoupled middleware.
I'd like to only make one request from the frontend to graphql to then retrieve data from drupal or any other source. Doesn't the graphql module goes against this philosophy or have I misunderstood something?

Related

Separate plugins or one giant plugin on WP

I’m building a WP plugin to enhance a website, and come to an interrogation with the workflow.
Basically, I have to create a custom post type, assorted with several custom taxonomies, which will be used/displayed on the frontend and backend, and create a backend section in order to interact with our CRM, and Supabase via their respective APIs (service centralisation).
All of the second part is only intended to be used/displayed on the admin section, to logged users.
However, when creating/saving a custom post type, or when viewing it from the frontend, I have to make a GET request to the CRM to fetch some data and store it in JSON somewhere (24h cache).
That I can do.
At the moment, I worked on the CPT part, and made a class to interact with the CRM, with credentials stored in wp_options. I now have to work on the backend part.
My question is: what are the best practices here? Keep it in a single plugin or divide into several plugins?
And if I divide, how should I turn it? 2 plugins, one for the CPT and one for the backend? Or go even deeper, and get the CRM and Supabase their own simple plugin, and call their methods to make my requests?
I am short of ideas here, so if you encountered this situation, could you enlighten me?

Is there any way to add CMS to Nextjs website (such as Wordpress)?

I developed a website using Nextjs (Client side only, and used Nextjs for the SEO).
I wanted to ask if there is a way to convert this website somehow from Nextjs to Wordpress or anything else, or even somehow connect it to CMS application, so my client can modify images and content any time he want by his own.
Currently, the web application in Nextjs is pretty static, all the pages and conntent are hard coded wroten.
All my data are in JSON files and such are the images in the website.
Yes! This is a pretty hot topic right now, and there are many ways to accomplish it.
Here are the general guidelines:
Set up a "headless CMS" - this can be WordPress (set up in a special way so you are using just the backend) - or there are many other popular options, such as Contentful, Sanity, Prismic...
Your CMS needs to have an API for Next.js to use. If you go with WordPress, you can use the built-in REST API - or you can use the WP GraphQL plugin
This is such a popular topic, that if you search around, you'll find many helpful guides that go into more detail. You'll want to search "Next.JS with WordPress headless CMS"
Here's one example I found that uses GraphQL and looks fairly thorough.
Or, if you're not set on WordPress, check out Next.js-specific information for other popular headless CMS's - most of them will have specific documentation and guides for Next.JS - for example Sanity's Next.JS Guides.
WordPress is solid and flexible - but if you're not already a fairly strong WP developer, then I might recommend going with one of the more pre-packaged options (like Sanity, Prismic, Contentful, etc.) - many of them have a free tier.

How to get Drupal 8 Views working with GraphQL / Gatsby.js

I'm struggeling to find an answer, because I'm not really sure if this is a Drupal, GraphQl or Gatsby question.
I'm building a portfolio-site with Gatsby.js and Drupal-8 as datasource (via gatsby-source-drupal).
GraphQl queries for Nodes, Taxonomy, Users, eg are working without problems.
But I can not access my created Views at my API-endpoint.
I have created a working Views-Page with a path.
I also exposed the data as a Block.
Tried a REST-Export as serialized JSON, but I can not get it working with JSON:API and JSON-Views-Module.
I expect to access the data from my View at my /jsonapi/endpoint, but my Views are not showing up.
I can't get my head around this. What am I missing? Is it even possible? Thanks!
TL;DR; You can't (from Drupal's JSON:API docs Unlike the REST module that comes with Drupal Core, JSON:API does not export Views results)
How to get filtered results
gatsby-source-drupal only fetches from the JSON:API endpoint (by default /jsonapi).
The way I see you can, kind of, emulate what Views does is using the filters options that gatsby-source-drupal provides.
The JSON:API Extras module for Drupal allows you to set some defaults filters as well.
Drupal documentation about filters
Example: ?filter[field_name]=value&filter[field_other]=value
Best!
With the JSON:API module you can not get views indeed, but there is also the GraphQl module and for your purpose the GraphQl views module that can make a view available to create a custom graphql schema. Good luck

SPA with content management

I would like to build Single Page Web Application (SPA) with React.js.
Application would need some Content Management System for back-end. I was thinking to use WordPress and their REST-API's but I don't know how to retrieve data from my wordpress installation.
Back-end and front-end would be in different domains so just building WP theme with React.js wouldn't work.
Basically, I don't know how to call and populate data from wordpress to my front-end.
I would need someone to point me to the right direction. And, maybe recommend easier CMS to use in this task.
Actually it is very easy to access your WordPress website data through HTTP REST API
Here you have the full documentation on WordPress REST APi
http://v2.wp-api.org/

Dynamic linking to Wordpress database

I intend to use WP to setup a freelancers website (similar to oDesk) to connect service providers with service seekers in a WEB 2.0 dynamic environment. This site requires multiple forms to enter and retrieve information using database and show them in filtered or non-filtered views in separate pages.
Please advise if there are available plugins to expedite developing this site, or otherwise any guidance would be appreciated. I specifically would like to know how to connect forms to database and then how to retrieve this information from the DB.
Regards,
You are likely going to have to create your own custom WordPress theme, using various custom PHP pages to connect your web forms to your database. I think your project is well beyond the scope of a simple WP plugin.
If this was my project, I'd ditch WordPress and go for something custom built in Rails. WordPress is a good enough CMS, but it isn't really a good fit for what you are looking to accomplish.

Resources