-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow customising graphql schema for a table (close #981) #2509
Conversation
Resolve Conflicts: server/src-lib/Hasura/Server/App.hs server/src-lib/Hasura/Server/Utils.hs
Deploy preview for hasura-docs ready! Built with commit 6309ce5 |
Review app for commit a19496d deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
@rakeshkky @0x777 why aren't we doing |
@ecthiender If you have a separate endpoint |
Resolve Conflicts: server/src-lib/Hasura/RQL/DDL/Schema/Table.hs server/src-lib/Hasura/RQL/Types/Common.hs
As of now, the only way to update I have a plan to add @0x777 @ecthiender @shahidhk thoughts? |
Review app for commit 48032f7 deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
It would be version nil (or 1) ideally, but if the code is easier managed if the version is 2, go ahead with 2. |
Resolve Conflicts: server/src-exec/Migrate.hs server/src-lib/Hasura/RQL/Types/SchemaCache.hs server/src-lib/Hasura/Server/App.hs server/src-lib/Hasura/Server/Query.hs
Review app for commit e0a5f4b deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
Review app for commit c8e1452 deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
Review app for commit 6b00fec deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
Resolve Conflicts: server/src-lib/Hasura/Server/Utils.hs
Review app for commit 7ffb524 deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
Resolve Conflicts: docs/graphql/manual/api-reference/schema-metadata-api/index.rst
Review app for commit 75f250e deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
dc67263
to
5973e2f
Compare
Review app for commit 5973e2f deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
Resolve Conflicts: server/src-exec/Migrate.hs server/src-lib/Hasura/GraphQL/Resolve/Insert.hs server/src-lib/Hasura/GraphQL/Resolve/Mutation.hs server/src-lib/Hasura/GraphQL/Resolve/Select.hs server/src-lib/Hasura/GraphQL/Schema.hs server/src-lib/Hasura/GraphQL/Schema/BoolExp.hs server/src-lib/Hasura/GraphQL/Schema/Common.hs server/src-lib/Hasura/GraphQL/Schema/Mutation/Common.hs server/src-lib/Hasura/GraphQL/Schema/Select.hs server/src-lib/Hasura/RQL/DDL/Schema/Table.hs server/src-lib/Hasura/RQL/DML/Internal.hs server/src-lib/Hasura/RQL/DML/Returning.hs server/src-lib/Hasura/RQL/GBoolExp.hs server/src-lib/Hasura/RQL/Types/Column.hs
@lexi-lambda Please have a final glance. Suggest the changes if any. |
Review app for commit 6309ce5 deployed to Heroku: https://hge-ci-pull-2509.herokuapp.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I am guessing console changes are going out as a separate PR |
Review app https://hge-ci-pull-2509.herokuapp.com is deleted |
…ra#2509) * allow customizing GraphQL root field names, close hasura#981 * document v2 track_table API in reference * support customising column field names in GraphQL schema * [docs] add custom column fields doc in API reference * add tests * rename 'ColField' to 'ColumnField' * embed column's graphql field in 'PGColumnInfo' -> Value constructor of 'PGCol' is not exposed -> Using 'parseJSON' to construct 'PGCol' in 'FromJSON' instances * avoid using 'Maybe TableConfig' * refactors & 'custom_column_fields' -> 'custom_column_names' * cli-test: add configuration field in metadata export test * update expected keys in `FromJSON` instance of `TableMeta` * use `buildSchemaCacheFor` to update configuration in v2 track_table * remove 'GraphQLName' type and use 'isValidName' exposed from parser lib * point graphql-parser-hs library git repo to hasura * support 'set_table_custom_fields' query API & added docs and tests
Requires merging hasura/graphql-parser-hs#17
TODO:-
Description
Allow users to customize root field names of a Postgres table and column fields in GraphQL schema. However, original Postgres column names are used to define metadata such as relationships, permissions etc.
Default root field names generated for a table
author
are:Queries:-
author
author_by_pk
author_aggregate
Mutations:-
insert_author
delete_author
update_author
TODO:- insert UI screenshots after console work is done.
Note:- Only root field names and columns are customizable as of now. I'm open to any request for customizing other parts of Hasura generated GraphQL schema
Affected components
Related Issues
#981
Solution and Design
A new optional
version
field whose type isInt
is introduced in/v1/query
payload which specifiesthe version of the query. If absent
version
is considered as1
. All existing query types come underversion: 1
track_table
query type is supported inversion: 2
.Example:-
A new
set_table_custom_fields
query type is added inversion: 2
. It is used to update the custom field names of an already tracked table.Example:-
Catalog changes:-
A new nullable column
configuration
of typeJSONB
is added to tablehdb_catalog.hdb_table
which stores the configuration JSON object found intrack_table
v2
query.For Console:
Refer docs to learn more about new
track_table
version2
API.NOTE: Tracking an already tracked table using version2
track_table
API won't throw API exception, instead it'll update the configuration in metadata cache and catalog.Steps to test and verify
Limitations, known bugs & workarounds