hasura graphql-engine is based on a very good pg of graphql engine, plv8 is an extension pg, we can use js write
functions, triggers, and for grammar es6 also has more complete support
Preparing the Environment
plv8 have built a good image contains a version of 2.3.13, 2.3.12 test used
- docker-compose documents
version: '3.6'
services:
postgres:
Image: dalongrong / plv8: 2.3.12
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD=dalong"
graphql-engine:
image: hasura/graphql-engine:v1.0.0-beta.9
ports:
- "8080:8080"
depends_on:
- "postgres"
environment:
HASURA_GRAPHQL_DATABASE_URL: Postgres: // Postgres: Dalong @ Postgres: 5432 / Postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
Start && test
- start up
docker-compose up -d
- plv8 extended configuration
contains an extended function is enabled and simple
CREATE EXTENSION plv8;
CREATE TYPE rec AS (i integer, t text);
CREATE or replace FUNCTION set_of_records() RETURNS SETOF rec AS
$$
was Results = [];
for(var index=1; index<1000000;index++) {
plv8.return_next( { "i": index, "t": "a"+index } );
}
$$
LANGUAGE plv8;
- effect
- Integrated use
By views
- schema effect
- Inquire
Explanation
The above is a simple integration, we can actually based plv8 powerful js capacity, very flexible expansion hasura graphql-engine, while plv8 for
support es6 is also very wide, and custom query function can also be provided at the same time hasura with plv integrating (process data generated by plv8, then return), the following
Reference Query
Reference material
https://github.com/plv8/plv8
https://github.com/hasura/graphql-engine
https://github.com/rongfengliang/plv8-docker