这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ If you do have such headers configured, then you must update the header configur

(Add entries here in the order of: server, console, cli, docs, others)

- server: fix failing introspection query when an enum column is part of a primary key (fixes #5200)
- server: disallow headers from env variables starting with `HASURA_GRAPHQL_` in actions, event triggers & remote schemas (#5519)
**WARNING**: This might break certain deployments. See `Breaking change` section above.
- server: bugfix to allow HASURA_GRAPHQL_QUERY_PLAN_CACHE_SIZE of 0 (#5363)
Expand Down
1 change: 1 addition & 0 deletions server/src-lib/Hasura/GraphQL/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ mkMutationTypesAndFieldsRole tn insPermM selFldsM updColsM delPermM pkeyCols con
(selFldsM ^.. _Just.traverse._SFPGColumn)
<> (insPermM ^. _Just._1)
<> (updColsM ^. _Just)
<> (pkeyCols ^. _Just.pkColumns.to toList)
allEnumReferences = allColumnInfos ^.. traverse.to pgiType._PGColumnEnumReference
in flip map allEnumReferences $ \enumReference@(EnumReference referencedTableName _) ->
let typeName = mkTableEnumType referencedTableName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# https://github.com/hasura/graphql-engine/issues/5200
description: Test introspecting enum types as user role
url: /v1/graphql
status: 200
headers:
X-Hasura-Role: user
response:
data:
country:
kind: ENUM
name: country_enum
enumValues:
- name: India
description: Republic of India
- name: USA
description: United States of America
zones:
fields:
- name: code
type:
ofType:
name: String
- name: id
type:
ofType:
name: Int
query:
query: |
{
country: __type(name: "country_enum") {
name
kind
enumValues {
name
description
}
}
zones: __type(name: "zones") {
fields {
name
type {
ofType {
name
}
}
}
}
}
31 changes: 31 additions & 0 deletions server/tests-py/queries/graphql_query/enums/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,34 @@ args:
('Alyssa', 'red'),
('Ben', 'blue');

CREATE TABLE country
( value text PRIMARY KEY
, comment text);
INSERT INTO country (value, comment) VALUES
('India', 'Republic of India'),
('USA', 'United States of America');

CREATE TABLE zones
( id SERIAL
, code text NOT NULL
, country text NOT NULL REFERENCES country
, PRIMARY KEY (code, country) );
INSERT INTO zones (code, country) VALUES
('67432', 'USA'),
('600036', 'India');

- type: track_table
args:
table: colors
is_enum: true
- type: track_table
args: users
- type: track_table
args:
table: country
is_enum: true
- type: track_table
args: zones

# Anonymous users can query users, but not colors
- type: create_select_permission
Expand All @@ -38,3 +60,12 @@ args:
permission:
columns: [id, name, favorite_color]
filter: {}

# A user can query only code but not country
- type: create_select_permission
args:
table: zones
role: user
permission:
columns: [id, code]
filter: {}
2 changes: 2 additions & 0 deletions server/tests-py/queries/graphql_query/enums/teardown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ args:
sql: |
DROP TABLE users;
DROP TABLE colors;
DROP TABLE zones;
DROP TABLE country;
cascade: true
3 changes: 3 additions & 0 deletions server/tests-py/test_graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ def dir(cls):
def test_introspect(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/introspect.yaml', transport)

def test_introspect_user_role(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/introspect_user_role.yaml', transport)

def test_select_enum_field(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_enum_field.yaml', transport)

Expand Down