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#a...
Re:EdgeDB: A New Beginning
by oneweekwonder on Friday April 13, 2018 @01:35AM
(#16827347)
You 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?
Re:EdgeDB: A New Beginning
by agborkowski86 on Friday April 13, 2018 @03:16AM
(#16827749)
postgraphile# is a good solution, even more this project allow u to write ur custom adapters for each db
Yes, automatic UI generation is something we've been doing with EdgeDB for years in our products. Having a uniform object data model and introspection makes it easy to automatically generated complex nested forms and grids. We'll likely build a React microframework to generate UIs for EdgeDB at some point after beta release.
Re:EdgeDB: A New Beginning
by oneweekwonder on Friday April 13, 2018 @01:51AM
(#16827416)
Have you looked at dumping json-schema? Because then something like json-editor[0] will just work out of the box.
Got extensively tested with swagger v2(openapi)[1].
After the json-schema you write a quick swagger spec and modify a couple of mustache templates[3] to generate a crud interface for server and client. In your language of choice.
All with one magic yaml file; but file format agnostic as well;
Personally I struggle to read the json format.
[0]: https://github.com/json-editor/json-editor [1]: https://github.com/swagger-api/swagger-editor/tree/2.x [3]: https://github.com/swagger-api/swagger-codegen/
Eg. if there is a m:n relationship do not make me enter some foreign key values into a join table but give me some nice autocomplete fields or checkboxes on either side of the relationships' types.
Or if there is some transitive relationship like "country -> city -> district -> office", give me some nice way to filter the list of offices by a given country oder district.
Auto generates this from the schema as web interface.
I already tried building this for SQL schemata but it seems like a schema definition as provided by EdgeDB seems predestined for this use case.