May 2020 Summaries
5 posts from Hasura
Filter
Month:
Year:
Post Summaries
Back to Blog
Relay is a JavaScript framework for declaratively fetching and managing GraphQL data. It enforces strict conventions to prevent developer errors and ensure performance as the app grows in size and complexity. The three main libraries of Relay are the Relay compiler, which analyzes any GraphQL inside your code during build time; the Relay runtime, a core runtime that is React-agnostic; and the React/Relay integration layer. Relay's key features include colocation, where data definitions and view definitions live together in each component, and fragments, which help write DRY queries. It also supports persisted queries for improved security and performance. The root query can be fetched using either the useLazyLoadQuery or usePreloadedQuery hooks, with the latter allowing more proactive data fetching. Relay requires a GraphQL server to follow its specifications, including providing a mechanism for refetching objects, describing how to page through connections, and structuring mutations to make them predictable.
May 29, 2020
2,548 words in the original blog post.
In this video series, a Yelp clone is built where users review planets from the science fiction series "Dune". The project involves creating search functionality, live reviews with real-time updates, and implementing business logic. Key steps include deploying to Heroku, setting up Apollo Client, tracking relationships between tables, routing, subscriptions, form creation, testing mutations, and adding action creators.
May 21, 2020
238 words in the original blog post.
This article discusses the concept of nullability in GraphQL and its implications. In GraphQL, all types are nullable by default, which is a departure from other typed languages where non-null types are the norm. The server returns a root field called errors for error handling purposes, while any fields with errors have the value null. Nulls become relevant when considering how to handle errors in GraphQL responses.
The article provides a cheatsheet on using nulls in queries and responses, as well as discussing the pros and cons of nullable vs non-null types. While some developers prefer nullable types for their ability to provide partial data even in case of errors, others find them cumbersome and prefer non-null types for guaranteed values.
Different GraphQL clients like Apollo and Relay have different approaches to handling nulls and errors. Apollo allows users to choose from three error policies: none (default), ignore, and all. On the other hand, Relay ignores GraphQL errors unless they affect the top-level data field or are explicitly thrown by the fetch function provided to the Relay Network.
The article concludes with a recommendation to make everything nullable except when it doesn't make sense, but ultimately leaves the decision up to individual developers based on their specific needs and preferences.
May 15, 2020
1,801 words in the original blog post.
Actions are a feature of Hasura that allow users to add custom business logic to their GraphQL API. They work well with existing CRUD operations and can be used in conjunction with serverless functions. Actions enable developers to maintain control over their data models, business logic, and security settings while leveraging the benefits of Hasura's scalable architecture and performance best practices. By using actions, users can create a command & query design that separates domain actions from model updates, making it easier to manage access control and maintain a consistent security posture. Additionally, Actions are not locked into any specific language or framework, allowing for flexibility in implementation.
May 05, 2020
1,569 words in the original blog post.
This post discusses building a customizable e-commerce backend using Hasura. The author outlines the use of technologies such as PostgreSQL for data storage and retrieval, Hasura Cloud for APIs and GraphQL engine projects, and Node.js for custom logic like authentication, cart, and order placements. The post then delves into the database schema and user workflow, focusing on core components like product listing with search, user authentication, cart page, coupon code validations, place order and payment, and email notifications to customers.
The author guides through setting up a Hasura Cloud project, data fetching APIs using GraphQL, filtering and sorting products, implementing product search functionality using Postgres functions or external services like Algolia, and fetching cart items with user-specific permissions. The post also covers user authentication using JWT tokens and custom business logic for add to cart inventory validation, coupon code validation, and payment processing with Stripe.
Lastly, the author discusses performance and scaling aspects of Hasura, emphasizing its lightweight nature, high performance, and ability to handle up to 1 million live subscriptions. The post concludes by highlighting that most data fetching requirements can be met using out-of-the-box GraphQL APIs from Hasura, with the option to quickly extend or override these APIs as needed.
May 01, 2020
1,792 words in the original blog post.