Skip to content
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

add computed fields support on console #3522

Merged
merged 36 commits into from
Jan 13, 2020

Conversation

rikinsk
Copy link
Member

@rikinsk rikinsk commented Dec 12, 2019

Description

Add support for adding computed fields via the console

TODO

  • verify migrations

Affected components

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System
  • Tests
  • Other (list it)

Related Issues

#3203 #3565

Solution and Design

Steps to test and verify

Limitations, known bugs & workarounds

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes
    • Does run_sql auto manages the new metadata through schema diffing?
      • Yes
      • Not required
    • Does run_sql auto manages the definitions of metadata on renaming?
      • Yes
      • Not required
    • Does export_metadata/replace_metadata supports the new metadata added?
      • Yes
      • Not required

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated:
    • New types and typenames are correlated

Breaking changes

  • No Breaking changes

  • There are breaking changes:

    1. Metadata API

      Existing query types:

      • Modify args payload which is not backward compatible
      • Behavioural change of the API
      • Change in response JSON schema
      • Change in error code
    2. GraphQL API

      Schema Generation:

      • Change in any NamedType
      • Change in table field names

      Schema Resolve:-

      • Change in treatment of null value for any input fields
    3. Logging

      • Log JSON schema has changed
      • Log type names have changed

@rikinsk rikinsk added c/console Related to console s/wip Status: This issue is a work in progress labels Dec 12, 2019
@netlify
Copy link

netlify bot commented Dec 12, 2019

Deploy preview for hasura-docs ready!

Built with commit 1f544d9

https://deploy-preview-3522--hasura-docs.netlify.com

@hasura-bot
Copy link
Contributor

Review app for commit 8cc5387 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-8cc53871

@hasura-bot
Copy link
Contributor

Review app for commit f7a39af deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-f7a39af9

@rikinsk rikinsk requested a review from lexi-lambda as a code owner December 18, 2019 10:14
@rikinsk rikinsk added the c/server Related to server label Dec 18, 2019
@hasura-bot
Copy link
Contributor

Review app for commit abdd967 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-abdd9674

@hasura-bot
Copy link
Contributor

Review app for commit 574248f deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-574248fa

@rikinsk rikinsk changed the title add computed fields support on console <WIP> add computed fields support on console Dec 18, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 713126b deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-713126b5

@hasura-bot
Copy link
Contributor

Review app for commit edd4bbc deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-edd4bbc5

@santicomp2014
Copy link

@rikinsk Hey nice job with this PR, I was wondering if this affected the computed field and roles.
Currently, I'm using a computed field, but when I query from a role it does not even appear as a field in the console neither from my frontend.

Should I create a new Issue?.
Thanks.

@darknoon
Copy link

Hey, this is really awesome and would fix one of my main gripes at the moment, which is creating views on my tables so I can add a computed field. My use case is signing URLs for S3 access, eg profile photo etc.

In the design, I think it would be clearer if the "function definition" area didn't show up until a matching function was found. I tried to start typing there, and took a sec to realize I needed to type in the exact name of the function.

What about a dropdown of existing functions?

Screen Shot 2019-12-18 at 12 21 25 PM

Anyway, looking forward to using this!

@lexi-lambda
Copy link
Contributor

  • SERVER: The metadata has been updated to track the hdb_computed_field_function view. Catalog migrations need to be figured out.

Interesting issue—we basically need an “empty” migration, just to get the metadata migrations to fire. That shouldn’t be difficult to do, and in fact it’s probably simplest to genuinely just create an empty SQL file for the migration, which I think should work? I’ll figure it out and push a change to this branch.

@rikinsk rikinsk requested a review from wawhal January 8, 2020 10:08
@hasura-bot
Copy link
Contributor

Review app for commit a0f7237 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-a0f72379

@ManUtopiK
Copy link

ManUtopiK commented Jan 8, 2020

Just tested the last deploy: https://hge-ci-pull-3522.herokuapp.com/
I think it missing computed fields permissions management. It should be something like "Computed fields select permissions" after column select permissions.

@ManUtopiK
Copy link

ManUtopiK commented Jan 8, 2020

Also, if there are two columns; first_name with public permission and last_name with private permission, could computed field full_name be public?

Edit:
I just tested with a POST query to /v1/query:

{
    "type" : "create_select_permission",
    "args" : {
        "table" : "author",
        "role" : "public",
        "permission" : {
            "columns" : ["first_name"],
            "computed_fields": ["full_name"],
            "filter": {}
        }
    }
}

And it works. full_name return first_name and last_name. It means that permission in computed field can override permission in column field. Developper should be careful with that.

@hasura-bot
Copy link
Contributor

Review app for commit b7e6c86 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-b7e6c86a

@hasura-bot
Copy link
Contributor

Review app for commit f1ab375 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-f1ab3751

@hasura-bot
Copy link
Contributor

Review app for commit 0028190 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-0028190a

@rikinsk
Copy link
Member Author

rikinsk commented Jan 10, 2020

This PR is finally feature complete and ready for merge

@marionschleifer @wawhal @lexi-lambda Please add your reviews .

@lexi-lambda The empty server migration file is now replaced by one added in another PR.

@rikinsk rikinsk merged commit db6b2aa into hasura:master Jan 13, 2020
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-3522.herokuapp.com is deleted

@rikinsk rikinsk deleted the console-computed-fields branch January 13, 2020 07:11
@hasura-bot
Copy link
Contributor

Review app for commit 1f544d9 deployed to Heroku: https://hge-ci-pull-3522.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3522-1f544d93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/console Related to console c/docs Related to docs c/server Related to server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants