github hasura/graphql-engine v1.3.0

latest releases: v2.38.1, cli/v2.38.1, cli/v2.38.0-patch.2...
3 years ago

Changelog

New features and highlights

Remote Joins

Remote Joins generalizes the concept of joining data between tables in Postgres, to being able to join data across any part of your GraphQL schema. The schema's underlying source can be anything: Postgres or REST APIs (via Actions) or other GraphQL services (via Remote Schemas), but you can still do a join across them by simply creating relationships via Hasura metadata.

Remote Joins enables complete data federation as your data sources can evolve independently while Hasura provides a unified GraphQL API over them with authorization and schema integrity enabled from get-go.

In this release, you can create relationships from tables to Remote Schemas. This works similar to table relationships. Head to the Relationship tab in your table page and define a Remote Relationship:

  • give a name for the relationship
  • select the remote schema
  • give the join configuration from table columns to remote schema fields.

remote-relationships

The join configuration can refer to any field in the remote schema that takes an input argument. It can also take static values.

remote-rel-configuration

Once this is done, head to GraphiQL and make your query with the remote relationship! Note: Action relationships are kind of a reverse join of this where you can create a relationship from your REST API to a table.

(#2392)

Relay

The Hasura GraphQL Engine now serves a Relay schema for Postgres tables which have a primary key defined. Relay allows you to combine React and GraphQL to build highly modular and performant javascript applications.

The Relay schema can be accessed through /v1beta1/relay endpoint.

relay

(#4458)

Scheduled Triggers

Scheduled Triggers can be used to invoke webhooks based on a cron schedule or timestamp. Head to the Events page on the console and check it out.

A Cron Trigger can be used to invoke webhooks on a fixed schedule. For example, you can create a Cron Trigger to generate an end-of-day sales report every weekday at 10 pm.

Selection_355

You can also schedule one-off events based on a timestamp. For example, a scheduled event can be created to send a feedback email to a user 2 days after sign-up (note: this would typically be done using the metadata API in your code).

Selection_356

(#3553, #4732)

Allow access to session variables in computed fields

Sometimes it is useful for computed fields to have access to the Hasura session variables directly. For example, suppose you want to fetch some articles but also get related user info, say likedByMe. Now, you can define a function like:

CREATE OR REPLACE FUNCTION article_liked(article_row article, hasura_session json)
RETURNS boolean AS $$
  SELECT EXISTS (
    SELECT 1
    FROM liked_article A
    WHERE A.user_id = hasura_session ->> 'x-hasura-user-id' AND A.article_id = article_row.id
  );
$$ LANGUAGE sql STABLE;

and make a query like:

query {
  articles {
    title
    content
    likedByMe
  }
}

Support for this is now added through the add_computed_field API.

Read more about the session argument for computed fields in the docs.

(fix #3846)

Manage seed migrations as SQL files

A new seeds command is introduced in CLI, this will allow managing seed migrations as SQL files

Creating seed

# create a new seed file and use editor to add SQL content
hasura seeds create new_table_seed

# create a new seed by exporting data from tables already present in the database
hasura seeds create table1_seed --from-table table1

# create from data in multiple tables:
hasura seeds create tables_seed --from-table table1 --from-table table2

Applying seed

# apply all seeds on the database:
hasura seeds apply

# apply only a particular seed
hasura seeds apply --file 1234_add_some_seed_data.sql

Other fixes and improvements

  • server: flush log buffer during shutdown (#4800)
  • server: raise error on startup when --unauthorized-role is ignored (#4736)
  • server: add new --conn-lifetime and HASURA_GRAPHQL_PG_CONN_LIFETIME options for expiring connections after some amount of active time (#5087)
  • server: shrink libpq connection request/response buffers back to 1MB if they grow beyond 2MB, fixing leak-like behavior on active servers (#5087)
  • server: add --pg-connection-options command-line flag for passing parameters to PostgreSQL (close #5092) (#5187)
  • server: adjustments to idle GC to try to free memory more eagerly (related to #3388)
  • console: allow entering big int values in the console (close #3667) (#4775)
  • console: add support for subscriptions analyze in API explorer (close #2541) (#2541)
  • console: avoid count queries for large tables (#4692)
  • console: fix regression in editing permissions manually (fix #4683) (#4826)
  • console: allow modifying default value for PK (fix #4075) (#4679)
  • console: fix checkbox for forwarding client headers in actions (#4595)
  • console: re-enable foreign tables to be listed as views (fix #4714) (#4742)
  • console: display rows limit in permissions editor if set to zero (fix #4559)
  • console: fix inconsistency between selected rows state and displayed rows (fix #4654) (#4673)
  • console: fix displaying boolean values in Edit Row tab (#4682)
  • console: fix underscores not being displayed on raw sql page (close #4754) (#4799)
  • console: fix visiting view modify page overwriting raw sql content (fix #4798) (#4810)
  • console: add new sidebar icon that separates enums from tables (fix #4984) (#4992)
  • console: provide option to cascade metadata on dependency conflicts on console (fix #1593)
  • console: fix enum tables reload data button UI (#4647)
  • console: fix "Cannot read property 'foldable'" runtime error in Browse Rows page (fix #4907) (#5016)
  • console: respect read-only mode in actions pages (fix #4656) (#4764)
  • console: allow configuring session_argument for custom functions (close #4499) (#4922)
  • console: allow manual edit of column types and handle array data types (close #2544, #3335, #2583) (#4546)
  • console: add the ability to delete a role in permissions summary page (close #3353) (#4987)
  • console: fix styling of table row contents on tables on relationship page (#4974)
  • console: allow configuring statement timeout on console RawSQL page (close #4998) (#5045)
  • console: support tracking partitioned tables (close #5071) (#5258)
  • console: handle generated and identity columns in console data section (close #4552, #4863) (#4761)
  • console: display line number that error originated from in GraphQL editor (close #4849) (#4942)
  • cli: list all available commands in root command help (fix #4623) (#4446
  • cli: fix bug with squashing event triggers (close #4883)
  • cli: add support for skipping execution while generating migrations through the migrate REST API
  • cli: add dry run flag in hasura migrate apply command (fix #3128) (#3499)
  • cli: load assets from server when HASURA_GRAPHQL_CONSOLE_ASSETS_DIR is set (close #3382)
  • cli: add new flags up-sql and down-sql to generate sql based migrations from the CLI (#5026)
  • cli: handle missing files during metadata apply (close #5163) (#5170)
  • cli: fix plugins install failing due to permission issues on windows (close #5111)
  • docs: add section on actions vs. remote schemas to actions documentation (#4284)
  • docs: fix wrong info about excluding scheme in CORS config (#4685)
  • docs: add single object mutations docs (close #4622) (#4625)
  • docs: add docs page on query performance (close #2316) (#3693)
  • docs: add a sample Caddyfile for Caddy 2 in enable-https section (#4710)
  • docs: add disabling dev mode to production checklist (#4715)
  • docs: add integration guide for AWS Cognito (#4822, #4843)
  • docs: update troubleshooting section with reference on debugging errors (close #4052) (#4825)
  • docs: add page for procuring custom docker images and binaries (#4828)
  • docs: add content on how to secure action handlers and other actions docs improvements (#4743)
  • docs: make header common with other hasura.io/ pages (#4957)
  • docs: add page on setting up v2 migrations (close #4746) (#4898)
  • docs: add note for managed databases in postgres requirements (close #1677, #3783) (#5228)
  • docs: add 1-click deployment to Nhost page to the deployment guides (#5180)
  • docs: add hasura cloud to getting started section (close #5206) (#5208)
  • docs: add page on created_at / updated_at timestamps (close #2880) (#5223)
  • install manifests: update all install manifests to enable dev mode by default (close #4599) (#4716)

Using this release

Use the following docker image:

hasura/graphql-engine:v1.3.0

Don't miss a new graphql-engine release

NewReleases is sending notifications on new releases.