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 a console button and an API endpoint to force HGE to reload or atleast refresh schema-cache #292

Closed
coco98 opened this issue Aug 17, 2018 · 6 comments
Assignees
Labels
c/console Related to console c/server Related to server design-rfc Picked up by product design team for RFC s/wip Status: This issue is a work in progress

Comments

@coco98
Copy link
Contributor

coco98 commented Aug 17, 2018

It'll be nice to have a UI feature and an API endpoint to force HGE to refresh its schema cache or reload entirely. In particular this is because #240 is still open.

Edit: Via @trash_art#6846 on discord

rakeshkky added a commit to rakeshkky/graphql-engine that referenced this issue Aug 18, 2018
@rakeshkky
Copy link
Member

@praveenweb
I added a query type to reload metadata:

POST /v1/query
{
  "type": "reload_metadata",
  "args": {}
}

Please push console changes to this branch

@praveenweb praveenweb added c/console Related to console c/server Related to server labels Aug 20, 2018
@rakeshkky rakeshkky added the s/wip Status: This issue is a work in progress label Aug 20, 2018
@praveenweb praveenweb added the design-rfc Picked up by product design team for RFC label Aug 27, 2018
@dsandip
Copy link
Member

dsandip commented Aug 29, 2018

@coco98 @praveenweb UI mockup for the console (Data -> Metadata; reference: https://hge-ci-pull-323.herokuapp.com/console/data/metadata)

metadata cache refresh

Also, modify the text if needed:

Metadata is cached to improve the query performance. The metadata and the cache are automatically updated when Postgres schema is modified using the GraphQL Engine console. You can also explicitly refresh the cache.

@coco98
Copy link
Contributor Author

coco98 commented Aug 29, 2018

Oh man. I'm very lost. Hasura metadata and then a heading called metadata cache is very confusing.
I'm thinking we should just have the hasura metadata heading and then different headings:

Import/export
Get Hasura metadata as JSON
<import> <export>

Refresh
Refresh Hasura metadata, typically required if you have changed the underlying postgres schema.
<refresh>

@dsandip
Copy link
Member

dsandip commented Aug 29, 2018

..changed the underlying postgres schema: Do we need to qualify this with " without using the GraphQL Engine console"?

@coco98
Copy link
Contributor Author

coco98 commented Aug 29, 2018

Not really. Because you won't be at this page unless you've made an error.

Also, please note in the screenshot below:
@karthikvt26 @surendran82

I've added 2 subheadings. Gap between buttons reduced from 60px to 30px.

screen shot 2018-08-29 at 5 12 28 pm

karthikvt26 pushed a commit to karthikvt26/graphql-engine that referenced this issue Sep 5, 2018
* add a query to reload schema cache (metadata), close hasura#292

* minor code refactor

* simpler root level select fields using primary keys (fix hasura#304) (hasura#306)

* select fields by primary key col values as argument values, fix hasura#304

* change field name 'table_by_pkey' to 'table_by_pk'

* add links to share and help (hasura#303)

* add req_user_id as alias to x-hasura-user-id (fix hasura#317) (hasura#320)

* fix insert fails for non-admin roles on v1/query  (fix hasura#327) (hasura#328)

* fix insert fails for non-admin roles on v1/query, fix hasura#327

* add test case for user role upsert usint constraint name

* mutation return type and query type are same (close hasura#315) (hasura#324)

* add support for jwt authorization (close hasura#186) (hasura#255)

The API:
1. HGE has `--jwt-secret` flag or `HASURA_GRAPHQL_JWT_SECRET` env var. The value of which is a JSON.

2. The structure of this JSON is: `{"type": "<standard-JWT-algorithms>", "key": "<the-key>"}`
`type` : Standard JWT algos : `HS256`, `RS256`, `RS512` etc. (see jwt.io).
`key`:
  i. Incase of symmetric key, the key as it is.
  ii. Incase of asymmetric keys, only the public key, in a PEM encoded string or as a X509 certificate.

3. The claims in the JWT token must contain the following:
  i. `x-hasura-default-role` field: default role of that user
  ii. `x-hasura-allowed-roles` : A list of allowed roles for the user. The default role is overriden by `x-hasura-role` header.

4. The claims in the JWT token,  can have other `x-hasura-*` fields where their values can only be strings.

5. The JWT tokens are sent as `Authorization: Bearer <token>` headers.

---
To test:
1. Generate a shared secret (for HMAC-SHA256) or RSA key pair.
2. Goto https://jwt.io/ , add the keys
3. Edit the claims to have `x-hasura-role` (mandatory) and other `x-hasura-*` fields. Add permissions related to the claims to test permissions.
4. Start HGE with `--jwt-secret` flag or `HASURA_GRAPHQL_JWT_SECRET` env var, which takes a JSON string: `{"type": "HS256", "key": "mylongsharedsecret"}` or `{"type":"RS256", "key": "<PEM-encoded-public-key>"}`
5. Copy the JWT token from jwt.io and use it in the `Authorization: Bearer <token>` header.

---
TODO: Support EC public keys. It is blocked on frasertweedale/hs-jose#61

* compare only major and minor versions for cli-server (fix hasura#331) (hasura#332)

* Revert "add links to share and help (hasura#303)" (hasura#334)

This reverts commit 798efdd.

* update tests to use access key (close hasura#113) (hasura#296)

Closes hasura#113

* generate a returning field in a mutation only when the select permission is defined (fix hasura#340) (hasura#341)

* allow selectively updating columns on a conflict during insert (fix hasura#342)

* fix primary key changing on upsert, fix hasura#342

* add 'update_columns' in 'on_conflict' object, consider 'allowUpsert'

* 'ConflictCtx' type should respect upsert cases

* validation for not null fields in an object

* console: fix error notification non json, auto height css (hasura#354)
@shahidhk
Copy link
Member

shahidhk commented Sep 5, 2018

Added in e3102df

@shahidhk shahidhk closed this as completed Sep 5, 2018
hasura-bot pushed a commit that referenced this issue Jan 19, 2024
V3_GIT_ORIGIN_REV_ID: 723bd361f8e7d136a02f58873b5edcf5089acf03
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/server Related to server design-rfc Picked up by product design team for RFC s/wip Status: This issue is a work in progress
Projects
None yet
Development

No branches or pull requests

6 participants