mirror of
https://github.com/hasura/graphql-engine.git
synced 2025-01-07 08:13:18 +03:00
18efbe9380
This PR refactors the schema crate to enable overriding the interpretation of roles at runtime. By providing a `NamespacedGetter` that ignores roles entirely (i.e. `GDSNamespacedGetterAgnostic`) to schema generation functions it is possible to derive a GraphQL schema that ignores permissions and presets. This PR leaves back a few opportunities to improve code clarity, which I hope to address in follow-up PRs. For instance, it seems superfluous to make sense for generic code parametrised `<S: SchemaContext>` to carry around both a `S::Namespace` and a `S::NamespaceGetter`, when all that code could ever do with that `S::Namespace` value anyway is apply it to the `S::NamespaceGetter`. Taking this line of reasoning to its conclusion suggests that we can reduce the complexity of `trait SchemaContext` and its associated types and kit. --------- Co-authored-by: Samir Talwar <samir.talwar@hasura.io> V3_GIT_ORIGIN_REV_ID: c84555fd88279582670919faa5a62bbd00b714bd
872 lines
30 KiB
JSON
872 lines
30 KiB
JSON
{
|
|
"version": "v2",
|
|
"subgraphs": [
|
|
{
|
|
"name": "default",
|
|
"objects": [
|
|
{
|
|
"kind": "CommandPermissions",
|
|
"version": "v1",
|
|
"definition": {
|
|
"commandName": "get_actors_by_movie_id_bounds",
|
|
"permissions": [
|
|
{
|
|
"role": "role_with_presets",
|
|
"allowExecution": true,
|
|
"argumentPresets": [
|
|
{
|
|
"argument": "lower_bound",
|
|
"value": {
|
|
"literal": 2
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"kind": "Command",
|
|
"version": "v1",
|
|
"definition": {
|
|
"name": "get_actors_by_movie_id_bounds",
|
|
"arguments": [
|
|
{
|
|
"name": "lower_bound",
|
|
"type": "Int!"
|
|
},
|
|
{
|
|
"name": "upper_bound",
|
|
"type": "Int!"
|
|
}
|
|
],
|
|
"outputType": "[commandActor]",
|
|
"source": {
|
|
"dataConnectorName": "custom",
|
|
"dataConnectorCommand": {
|
|
"function": "get_actors_by_movie_id_bounds"
|
|
},
|
|
"argumentMapping": {
|
|
"lower_bound": "lower_bound",
|
|
"upper_bound": "upper_bound"
|
|
}
|
|
},
|
|
"graphql": {
|
|
"rootFieldName": "getActorsByMovieIdBounds",
|
|
"rootFieldKind": "Query"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "default",
|
|
"objects": [
|
|
{
|
|
"kind": "DataConnectorLink",
|
|
"version": "v1",
|
|
"definition": {
|
|
"name": "custom",
|
|
"url": {
|
|
"singleUrl": {
|
|
"value": "http://custom_connector:8101"
|
|
}
|
|
},
|
|
"headers": {},
|
|
"schema": {
|
|
"version": "v0.1",
|
|
"schema": {
|
|
"scalar_types": {
|
|
"Actor_Name": {
|
|
"aggregate_functions": {},
|
|
"comparison_operators": {}
|
|
},
|
|
"Int": {
|
|
"aggregate_functions": {
|
|
"max": {
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"min": {
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"comparison_operators": {
|
|
"_eq": {
|
|
"type": "equal"
|
|
}
|
|
}
|
|
},
|
|
"String": {
|
|
"aggregate_functions": {},
|
|
"comparison_operators": {
|
|
"_eq": {
|
|
"type": "equal"
|
|
},
|
|
"like": {
|
|
"argument_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
},
|
|
"type": "custom"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"object_types": {
|
|
"actor": {
|
|
"description": "An actor",
|
|
"fields": {
|
|
"id": {
|
|
"description": "The actor's primary key",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"movie_id": {
|
|
"description": "The actor's movie ID",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"name": {
|
|
"description": "The actor's name",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"movie": {
|
|
"description": "A movie",
|
|
"fields": {
|
|
"id": {
|
|
"description": "The movie's primary key",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"rating": {
|
|
"description": "The movie's rating",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"title": {
|
|
"description": "The movie's title",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"name_query": {
|
|
"description": "parameters for querying by name",
|
|
"fields": {
|
|
"first_name": {
|
|
"description": "The actor's first name or null to match any first name",
|
|
"type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
},
|
|
"last_name": {
|
|
"description": "The actor's last name or null to match any last",
|
|
"type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"institution": {
|
|
"description": "An institution",
|
|
"fields": {
|
|
"departments": {
|
|
"description": "The institution's departments",
|
|
"type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
},
|
|
"id": {
|
|
"description": "The institution's primary key",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"location": {
|
|
"description": "The institution's location",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "location"
|
|
}
|
|
},
|
|
"name": {
|
|
"description": "The institution's name",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
},
|
|
"staff": {
|
|
"description": "The institution's staff",
|
|
"type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "staff_member"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"location": {
|
|
"description": "A location",
|
|
"fields": {
|
|
"campuses": {
|
|
"description": "The location's campuses",
|
|
"type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
},
|
|
"city": {
|
|
"description": "The location's city",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
},
|
|
"country": {
|
|
"description": "The location's country",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"staff_member": {
|
|
"description": "A staff member",
|
|
"fields": {
|
|
"first_name": {
|
|
"description": "The staff member's first name",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
},
|
|
"last_name": {
|
|
"description": "The staff member's last name",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
},
|
|
"specialities": {
|
|
"description": "The staff member's specialities",
|
|
"type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
},
|
|
"favourite_artist_id": {
|
|
"description": "The artist_id of the staff member's favourite artist",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"collections": [
|
|
{
|
|
"name": "actors",
|
|
"description": "A collection of actors",
|
|
"arguments": {},
|
|
"type": "actor",
|
|
"uniqueness_constraints": {
|
|
"ActorByID": {
|
|
"unique_columns": ["id"]
|
|
}
|
|
},
|
|
"foreign_keys": {}
|
|
},
|
|
{
|
|
"name": "movies",
|
|
"description": "A collection of movies",
|
|
"arguments": {},
|
|
"type": "movie",
|
|
"uniqueness_constraints": {
|
|
"MovieByID": {
|
|
"unique_columns": ["id"]
|
|
}
|
|
},
|
|
"foreign_keys": {}
|
|
},
|
|
{
|
|
"name": "institutions",
|
|
"description": "A collection of institutions",
|
|
"arguments": {},
|
|
"type": "institution",
|
|
"uniqueness_constraints": {
|
|
"InstitutionByID": {
|
|
"unique_columns": ["id"]
|
|
}
|
|
},
|
|
"foreign_keys": {}
|
|
},
|
|
{
|
|
"name": "actors_by_movie",
|
|
"description": "Actors parameterized by movie",
|
|
"arguments": {
|
|
"movie_id": {
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"type": "actor",
|
|
"uniqueness_constraints": {},
|
|
"foreign_keys": {}
|
|
},
|
|
{
|
|
"name": "movies_by_actor_name",
|
|
"description": "Movies filtered by actor name search parameters",
|
|
"arguments": {
|
|
"actor_name": {
|
|
"description": "the actor name components to search by",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "name_query"
|
|
}
|
|
}
|
|
},
|
|
"type": "movie",
|
|
"uniqueness_constraints": {},
|
|
"foreign_keys": {}
|
|
}
|
|
],
|
|
"functions": [
|
|
{
|
|
"name": "latest_actor_id",
|
|
"description": "Get the ID of the most recent actor",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "latest_actor_name",
|
|
"description": "Get the name of the most recent actor",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "Actor_Name"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "latest_actor",
|
|
"description": "Get the most recent actor",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_actor_by_id",
|
|
"description": "Get actor by ID",
|
|
"arguments": {
|
|
"id": {
|
|
"description": "the id of the actor to fetch",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_movie_by_id",
|
|
"description": "Get movie by ID",
|
|
"arguments": {
|
|
"movie_id": {
|
|
"description": "the id of the movie to fetch",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "movie"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_actors_by_name",
|
|
"description": "Get actors by name",
|
|
"arguments": {
|
|
"name": {
|
|
"description": "the name components to search by",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "name_query"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "actor_names_by_movie",
|
|
"description": "Get actor names by movie ID",
|
|
"arguments": {
|
|
"movie_id": {
|
|
"description": "the id of the movie to fetch",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_all_actors",
|
|
"description": "Get list of all actors",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_actors_by_movie_id_bounds",
|
|
"description": "Get all actors within a given lower and upper movie id bound",
|
|
"arguments": {
|
|
"lower_bound": {
|
|
"description": "the lower bound for movie id",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"upper_bound": {
|
|
"description": "the upper bound for movie id",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_actors_by_bool_exp",
|
|
"description": "Get all actors with a boolean expression",
|
|
"arguments": {
|
|
"actor_bool_exp": {
|
|
"description": "boolean expression over actor",
|
|
"type": {
|
|
"type": "predicate",
|
|
"object_type_name": "actor"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_actors_by_movie_id",
|
|
"description": "Get all actors from a movie by movie ID",
|
|
"arguments": {
|
|
"movie_id": {
|
|
"description": "the id of the movie to fetch the actors from",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "get_institutions_by_institution_query",
|
|
"description": "Get institutions by specifying parts of institution object. For example by 'location.city'. All fields are optional.",
|
|
"arguments": {
|
|
"institution_query": {
|
|
"description": "The institution query object. All fields are optional",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "institution"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "institution"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"procedures": [
|
|
{
|
|
"name": "upsert_actor",
|
|
"description": "Insert or update an actor",
|
|
"arguments": {
|
|
"actor": {
|
|
"description": "The actor to insert or update",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "update_actor_name_by_id",
|
|
"description": "Update an actor name given the ID and new name",
|
|
"arguments": {
|
|
"id": {
|
|
"description": "the id of the actor to update",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
},
|
|
"name": {
|
|
"description": "the new name of the actor",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "noop_procedure",
|
|
"description": "Procedure which does not perform any actual mutuations on the data",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "uppercase_actor_name_by_id",
|
|
"description": "Uppercase an actor name given the ID",
|
|
"arguments": {
|
|
"id": {
|
|
"description": "the id of the actor to update",
|
|
"type": {
|
|
"type": "named",
|
|
"name": "Int"
|
|
}
|
|
}
|
|
},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "uppercase_all_actor_names",
|
|
"description": "Uppercase all actor names",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "actor"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "uppercase_all_actor_names_return_names_list",
|
|
"description": "Uppercase all actor names and return a list of the updated names",
|
|
"arguments": {},
|
|
"result_type": {
|
|
"type": "nullable",
|
|
"underlying_type": {
|
|
"type": "array",
|
|
"element_type": {
|
|
"type": "named",
|
|
"name": "String"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"capabilities": {
|
|
"capabilities": {
|
|
"query": {
|
|
"explain": {},
|
|
"aggregates": {},
|
|
"variables": {}
|
|
},
|
|
"mutation": {},
|
|
"relationships": {
|
|
"relation_comparisons": {},
|
|
"order_by_aggregate": {}
|
|
}
|
|
},
|
|
"version": "0.1.0"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "default",
|
|
"objects": [
|
|
{
|
|
"kind": "DataConnectorScalarRepresentation",
|
|
"version": "v1",
|
|
"definition": {
|
|
"dataConnectorName": "custom",
|
|
"dataConnectorScalarType": "String",
|
|
"representation": "String",
|
|
"graphql": {
|
|
"comparisonExpressionTypeName": "String_Comparison_Exp"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "DataConnectorScalarRepresentation",
|
|
"version": "v1",
|
|
"definition": {
|
|
"dataConnectorName": "custom",
|
|
"dataConnectorScalarType": "Int",
|
|
"representation": "Int"
|
|
}
|
|
},
|
|
{
|
|
"kind": "ObjectType",
|
|
"version": "v1",
|
|
"definition": {
|
|
"name": "commandActor",
|
|
"fields": [
|
|
{
|
|
"name": "actor_id",
|
|
"type": "Int!"
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "String!"
|
|
},
|
|
{
|
|
"name": "movie_id",
|
|
"type": "Int!"
|
|
}
|
|
],
|
|
"graphql": {
|
|
"typeName": "CommandActor"
|
|
},
|
|
"dataConnectorTypeMapping": [
|
|
{
|
|
"dataConnectorName": "custom",
|
|
"dataConnectorObjectType": "actor",
|
|
"fieldMapping": {
|
|
"actor_id": {
|
|
"column": {
|
|
"name": "id"
|
|
}
|
|
},
|
|
"name": {
|
|
"column": {
|
|
"name": "name"
|
|
}
|
|
},
|
|
"movie_id": {
|
|
"column": {
|
|
"name": "movie_id"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"kind": "ObjectType",
|
|
"version": "v1",
|
|
"definition": {
|
|
"name": "commandMovie",
|
|
"fields": [
|
|
{
|
|
"name": "movie_id",
|
|
"type": "Int!"
|
|
},
|
|
{
|
|
"name": "title",
|
|
"type": "String!"
|
|
},
|
|
{
|
|
"name": "rating",
|
|
"type": "Int!"
|
|
}
|
|
],
|
|
"graphql": {
|
|
"typeName": "CommandMovie"
|
|
},
|
|
"dataConnectorTypeMapping": [
|
|
{
|
|
"dataConnectorName": "custom",
|
|
"dataConnectorObjectType": "movie",
|
|
"fieldMapping": {
|
|
"movie_id": {
|
|
"column": {
|
|
"name": "id"
|
|
}
|
|
},
|
|
"title": {
|
|
"column": {
|
|
"name": "title"
|
|
}
|
|
},
|
|
"rating": {
|
|
"column": {
|
|
"name": "rating"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|