How to use GraphQL supbscription with react-relay? - reactjs

How can I use the GraphQL subscriptions with React-Relay ?
I found a solution using relay-subscriptions package, but I'm still looking for a solution provided by Relay only without any extra packages.
PS: I'm using a graphql hosted plateform provided by Scaphoold.io

Here is a new tutorial on how you can setup GraphQL Subscriptions with react.
https://scaphold.io/blog/2016/11/09/build-realtime-apps-with-subs.html
I haven't spent enough time with subscriptions in relay yet but they are super easy to setup with Apollo Client, can run alongside relay, and will work with Scaphold immediately! I hope this helps!

Have you tried using this package?
GraphQL Relay Subscription
Seems promising, but I haven't actually tried it out myself.

Related

Storybook in Salesforce Lightning or alternative

Recently I've joined a new job and they are working with Salesforce. They have all pages with APEX and I propose to migrate to Lightning components.
I've created the first 7 components and I'm using Atomic Design Methodology (https://atomicdesign.bradfrost.com/chapter-2/) to develop these components.
I want to implement stories (with Storybook) or another similar library to document and put examples of each web component.
My question is... Is it possible? I try to install Storybook in the project and isn't working. The question is simple, whether or not you can. And if not, if you know any alternative to it.
Thank you!
In order to use Storybook, you will need to follow the provided Storybook documentation for lightning "Web Component" rather than the other available options like React and configure your VS Code to work with your SF Environment. Also, you might want to look into downloading the lwc-services, lwc-webpack-plugin and mo-dx-plugin dependency.

Is it possible to build a .net graphql backend and a react with redux frontend?

The company I am working for has a strong .NET and Microsoft SQL Server backend that I can not change. But we are front-end agnostic. Lately we have been in need of upgrading one of our older apps and I have been looking for solutions. I am looking to use React and Redux as I think they would be the closest to a single code base application between web and native applications. But I need to figure out how I can make sure React can work with .NET and MSS.
So far I have thought about starting with building an ASP.NET Core 2 GraphQL API backend which I know will work with MSS. But I am not sure how that would work with Redux. Here is the article I would start from:
https://fullstackmark.com/post/17/building-a-graphql-api-with-aspnet-core-2-and-entity-framework-core
I have also looked into using Apollo Server, but I am not sure if I would have to add another .Net layer in between Apollo and MSS.
I am just wondering if anyone has any experience in this stack so I can prevent myself from re-inventing the wheel. Any thoughts, suggestions, articles would be helpful and appreciative.
I am currently working on a project that uses React with TypeScript & GraphQL (among other things) and a C# .NET Backend. We use https://github.com/graphql-dotnet/graphql-dotnet on the server side which works pretty well.
We aren't using Redux, but I don't see why that should be an impediment. Any issues with compatability between GraphQL and Redux shouldn't have anything to do with the server implementation.
There are plenty of Articles on the internet that talk about using both.
https://www.robinwieruch.de/react-redux-apollo-client-state-management-tutorial
https://medium.com/react-weekly/implementing-graphql-in-your-redux-app-dad7acf39e1b
https://www.freecodecamp.org/news/tutorial-how-to-use-graphql-in-your-redux-app-9bf8ebbeb362/
I think the question is a bit unclear:
If you claim that your API is front-end agnostic then why shouldn't it work with React/Redux Or any other front end technologies?
As For GraphQL, In my opinion React Is a decent choice to consume GraphQL APIs as they are both managed by the same company.
For .Net GraphQL Framework I'd Recommend Hot Chocolate. It's an fast growing open source graphQL server framework for .NET technologies.
Also As Front-end GraphQL Frameworks Relay might also be a good choice as it's more powerful than other graphql clients but tends to be more complex.
But the main question you should ask yourself is if you really need to use GraphQL at all. If your API is not too generalized and you know exactly when and how each data endpoint is going to be used, then why not go with REST? As you might know GraphQL has it's limitations and is not an universal solution.
Here Are some articles which explain when to use GraphQL over rest and when to do otherwise:
Rubrik.com: GraphQL vs REST
stablekernel.com: Advantages and disadvantages of GraphQL
dzone.com: when and why to use GraphQL

Integrate reactjs with postgraphile

Am new to reactjs trying to integrate postgres with reactjs. Is there any way to integrate postgraphile with reactjs.
If so, please help me with a code or tutorial link.
Here are a collection of app examples using PostGraphile, some of these involve React:
https://github.com/graphile/postgraphile/wiki/App-Examples
Also check out https://github.com/graphile/examples and https://github.com/graphile/bootstrap-react-apollo
While there's already an accepted answer here, it missed stating something obvious: the way you "integrate reactjs and postgraphile" is by using a GraphQL client library (eg. Apollo, Relay, Lokka, etc.) in your React application to access the API that postgraphile creates.

Universal rendering for react app based on create-react-app

I have an app based on the create-react-app starter kit and need to switch to universal/server rendering due to SEO issues.
Is there an easy way or example of taking the create-react-app teamplate and adding or modifying it to support universal rendering?
A lot of the examples I see for universal are overly complex for my needs and I prefer to keep it very clean and simple, if possible.
Thanks.
EDIT: FYI,
I found this medium post which points at this repository.
Seems simple enough, but since I'm a newbie on all webpack/react/node related stuff, if anyone thinks it's the wrong approach, would love to know...
There was a proof of concept of adding server rendering in this PR.
I can’t speak to how good it is but it’s something you could start with.
You may also look at some of the alternatives.
A few of them provide server rendering out of the box.
I've just created react universal (server-side rendering) starter used recommendations from redux and react-router v4. Fill free for feedback
https://github.com/gzoreslav/react-redux-saga-universal-application
You can take your app (bootstrapped with Create React App) to the next level by replacing react-scripts with a slightly altered version - react-app-tools, which allows adding server-side code to your project (e.g. for server-side rendering purposes and/or implementing an API endpoint). It will allow compiling and running your app using normal Create React App pipeline, using a single instance of Webpack, on the same HTTP port.
You can find more info by visiting React App SDK.

React / Relay server side rendering and SEO friendly application

What is the most reliable way/approach to build React/Relay/GraphQL SEO friendly application with server side rendering ?
Some time ago I wrote isomorphic-relay and isomorphic-relay-router to solve exactly that problem. And I still support and update them, as they are still very actual. Personally I use these libraries in my projects, and other people also use them in production.
I would checkout Next.js together with relay-nextjs package.
Next.js solves SSR,the relay-nextjs package as a glue for Relay.
Also, I recommend check on this medium.com article

Resources