[service] name = "subgraph_tests" version = "1.0.0" port = 0 log_level = "debug" imports = ["./test_config_imports.toml"] [service.auth] requesting_party = "localhost" #"localhost" requesting_party_name = "$TRICERATASK_RPN" #"localhost_demo" requesting_party_origin = "$TRICERATASK_RPO" #"http://localhost:1234" #Origin of the client. http://localhost:1234 data_source = "users_data_source" private_key = "$TRICERATASK_PRIVATE_KEY" # Generate a private key using cli. # Data Sources [[service.data_sources]] [service.data_sources.Mongo] name = "users_data_source" uri = "mongodb://subgraph_mongo:subgraph_mongo@127.0.0.1:27017/subgraph_mongo" db = "subgraph_mongo" [[service.data_sources]] [service.data_sources.SQL] name = "coffee_data_source" uri = "sqlite:/home/nickisyourfan/Desktop/DEV/@the-devoyage/subgraph/tests/sqlite/subgraph_sqlite.db" dialect = "SQLITE" [[service.data_sources]] [service.data_sources.HTTP] name = "todos" url = "https://jsonplaceholder.typicode.com" [[service.data_sources]] [service.data_sources.SQL] name = "comments" uri = "postgres://root:rootroot@localhost:5432/postgres_db" dialect = "POSTGRES" [[service.data_sources]] [service.data_sources.SQL] name = "cars" uri = "mysql://root:rootroot@localhost:3306/mysql_db" dialect = "MYSQL" [[service.entities]] name = "user_access" fields = [ { name = "_id", scalar = "ObjectID", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"]}, { name = "user_id", scalar = "ObjectID", required = true }, { name = "view", scalar = "Boolean", required = true } ] # Entities [[service.entities]] name = "user" fields = [ { name = "_id", scalar = "ObjectID", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"]}, { name = "name", scalar = "String", required = true }, { name = "age", scalar = "Int", required = false }, { name = "married", scalar = "Boolean", required = true }, { name = "email", scalar = "String", required = true, exclude_from_input = ["UpdateMany"]}, { name = "middle_name", scalar = "String", default_value = "if(resolver_type() == \"CreateOne\", \"jack\", ())" }, { name = "address", scalar = "Object", fields = [ { name = "line_one", scalar = "String", required = true }, { name = "line_two", scalar = "String" }, { name = "city", scalar = "String", required = true }, { name = "state", scalar = "String", required = true }, { name = "zip", scalar = "String", required = true }, ] }, { name = "fail_guard", scalar = "Boolean", guards = [{name = "access_check", if_expr = "1 == 1", then_msg = "You do not have access to this resource" }] }, { name = "user_access", scalar = "ObjectID", as_type = "user_access", join_on = "user_id", join_from = "_id", eager = true }, { name = "virtual_id", scalar = "String", is_virtual = true }, { name = "birthday", scalar = "DateTime" }, { name = "uuid", scalar = "UUID" }, ] [[service.entities.guards]] name = "data_context_guard" if_expr = "every(context(\"user_access.user_id\"), \"6510865e93142f6d61b10dd2\")" then_msg = "You do not have access to this resource" [[service.entities.guards.context]] entity_name = "user_access" query = ''' { "get_user_accesss_input": { "query": { "user_id": "6510865e93142f6d61b10dd8" } } } ''' variables = [] [[service.entities]] name = "coffee" data_source = { from = "coffee_data_source" } fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "name", scalar = "String", required = true }, { name = "price", scalar = "Int", required = true }, { name = "available", scalar = "Boolean", required = true }, { name = "created_by", scalar = "ObjectID", as_type = "user", join_on = "_id" }, { name = "orders", scalar = "Int", list = true, as_type = "coffee_order", join_on = "coffee_id", join_from = "id", eager = true }, { name = "virtual_id", scalar = "String", is_virtual = true } ] [[service.entities]] name = "coffee_order" data_source = { from = "coffee_data_source" } fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "coffee_id", scalar = "Int", default_value = "1", primary_key = true }, { name = "status", scalar = "String", default_value = "\"pendingg\"" }, { name = "created_by", scalar = "ObjectID" }, { name = "uuid", scalar = "UUID", required = true }, { name = "order_date", scalar = "DateTime" } ] [[service.entities]] name = "todo" fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "userId", scalar = "Int", required = true }, { name = "title", scalar = "String", required = true }, { name = "completed", scalar = "Boolean", required = true } ] [service.entities.data_source] from = "todos" path = "/todos" [service.entities.data_source.resolvers] [service.entities.data_source.resolvers.find_one] path = "/:id" search_query = [["userId", ":userId"], ["title", ":title"]] [service.entities.data_source.resolvers.find_many] search_query = [["userId", ":userId"], ["completed", ":completed"], ["id", ":id"]] [[service.entities]] name = "comment" required = true data_source = { from = "comments", table = "comments" } fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "content", scalar = "String", required = true }, { name = "status", scalar = "Boolean", required = true}, { name = "reactions", scalar = "Int", list = true, as_type = "reaction", join_on = "comment_id", join_from = "id", eager = true }, { name = "virtual_id", scalar = "String", is_virtual = true } ] [[service.entities]] name = "reaction" required = true data_source = { from = "comments", table = "reactions" } fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "content", scalar = "String", default_value = "\"like\""}, { name = "status", scalar = "Boolean", required = true}, { name = "comment_id", scalar = "Int", as_type = "comment", join_on = "comment_id", join_from = "id", eager = true, default_value = "1" }, { name = "uuid", scalar = "UUID", required = true}, { name = "reaction_date", scalar = "DateTime", required = true} ] [[service.entities]] name = "car" required = true data_source = { from = "cars", table = "cars" } fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "model", scalar = "String", required = true }, { name = "price", scalar = "Int", required = true }, { name = "status", scalar = "Boolean", required = true }, { name = "purchases", scalar = "Int", as_type = "car_purchase", join_on = "car_id", join_from = "id", eager = true }, { name = "virtual_id", scalar = "String", is_virtual = true } ] [[service.entities]] name = "car_purchase" required = true data_source = { from = "cars", table = "orders" } fields = [ { name = "id", scalar = "Int", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "car_id", scalar = "Int", as_type = "car", join_on = "id", eager = true, default_value = "0 + 1" }, { name = "buyer", scalar = "String", required = true }, { name = "price", scalar = "Int", required = true }, { name = "status", scalar = "String", required = true }, { name = "uuid", scalar = "UUID", required = true }, { name = "order_date", scalar = "DateTime", required = true } ] [[service.entities]] name = "Beer" fields = [ { name = "_id", scalar = "ObjectID", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "name", scalar = "String", required = true }, { name = "ratings", scalar = "Int", required = true, list = true }, { name = "brand", scalar = "Object", required = true, fields = [ { name = "name", scalar = "String", required = true }, ]} ] [[service.entities]] name = "Dog" fields = [ { name = "_id", scalar = "ObjectID", required = true, exclude_from_input = ["CreateOne", "UpdateOne", "UpdateMany"] }, { name = "name", scalar = "String", required = true }, { name = "age", scalar = "Int", required = true }, { name = "owner", scalar = "ObjectID", as_type = "user", join_on = "_id" }, { name = "fav_car", scalar = "Int", as_type = "car", join_on = "id" }, { name = "fav_coffee", scalar = "Int", as_type = "coffee", join_on = "id" }, { name = "todo", scalar = "Int", as_type = "todo", join_on = "id" }, { name = "comments", scalar = "Int", as_type = "comment", join_on = "id", list = true }, ]