3 ms·
I recently tried Postgraphile [1] on an existing postgres database (briefly just for fun, not in prod) and it sort of does what you want. As long as the foreign
by zawerf 9y ago
I recently tried Postgraphile [1] on an existing postgres database (briefly just for fun, not in prod) and it sort of does what you want. As long as the foreign keys are there, it will generate the correct graphql queries. It even pluralizes the query names depending on whether it's a one-to-one or one-to-many relationship. Once it's in graphql you can just use the interactive graphql endpoint which has autocomplete and documentation to write your queries.
A schema like:
create table post (
id serial primary key,
author_id int non null references user(id),
headline text,
body text,
...
);
Can query relations like so:
allPosts {
edges {
node {
headline
body
author: userByAuthorId {
name
}
}
}
}
[1] https://github.com/graphile/postgraphile/tree/postgraphile#automatic-relation-detection https://github.com/graphile/postgraphile/tree/postgraphile#a...
- oneweekwonder 9y agoYou aware of any graphsql layer for postgres implemented in pgsql or pl/python? Something like using JSONB datatype in a entity key value store table. Mapping materialized views using pgsql json functions. To flatten out the data into sql tables for normal consumption?
- agborkowski86 9y agopostgraphile# is a good solution, even more this project allow u to write ur custom adapters for each db