diff --git a/README.md b/README.md index 1b5b652..5d636f1 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@
  • `@transforms`
  • `@sequence`
  • protection
  • +
  • `@dbquery`
  • `@rest` calls and responses
  • @@ -92,6 +93,9 @@ In `/protection`, you will find several subdirectories. Each contains a `.graphq - `/makeAllPublic` shows how you can easily make all queries public. - `/makeSomePublic` shows how you can make some public, and some private (which can still be accessed using your `admin` or `service` keys) +## @dbquery + +View the StepZen [documentation](https://stepzen.com/docs/custom-graphql-directives/directives#-dbquery) on the custom directive `@dbquery`. ## @rest calls and responses diff --git a/dbquery/query/api.graphql b/dbquery/query/api.graphql new file mode 100644 index 0000000..544c95f --- /dev/null +++ b/dbquery/query/api.graphql @@ -0,0 +1,53 @@ +type Address { + city: String + countryRegion: String + id: Int! + postalCode: String + stateProvince: String + street: String +} + +type Customer { + email: String! + id: Int! + name: String! +} + +type Order { + carrier: String! + createdAt: Date! + customerId: Int! + id: Int! + shippingCost: Float + trackingId: String! +} + +""" +These are some examples of queries generated from the schema. Feel free to modify them or add your own. +""" +type Query { + getCustomerUsingCustomerAddress(id: Int!): [Customer] + @dbquery( + type: "mysql" + query: """ + SELECT T.`email`, T.`id`, T.`name` + FROM `customer` T, `customerAddress` V + WHERE V.`addressId` = ? + AND V.`customerId` = T.`id` + """ + configuration: "mysql_config" + ) + +} +""" +These are some examples of mutations generated from the schema. Feel free to modify them or add your own. +""" +type Mutation { + +updateCustomerEmail(customer_id:Int! email:String): Customer + @dbquery( + type:"mysql" + query:"UPDATE customer SET email = ? WHERE customer.id = customer_id ?" + configuration: "mysql_config") + +} \ No newline at end of file diff --git a/dbquery/query/config.yaml b/dbquery/query/config.yaml new file mode 100644 index 0000000..9be454c --- /dev/null +++ b/dbquery/query/config.yaml @@ -0,0 +1,4 @@ +configurationset: + - configuration: + name: mysql_config + dsn: testUserIntrospection:HurricaneStartingSample1934@tcp(db.introspection.stepzen.net)/introspection diff --git a/dbquery/query/index.graphql b/dbquery/query/index.graphql new file mode 100644 index 0000000..458a6cd --- /dev/null +++ b/dbquery/query/index.graphql @@ -0,0 +1,3 @@ +schema @sdl(files:[ + "api.graphql" + ]){query: Query} \ No newline at end of file diff --git a/dbquery/query/stepzen.config.json b/dbquery/query/stepzen.config.json new file mode 100644 index 0000000..4d5ddb3 --- /dev/null +++ b/dbquery/query/stepzen.config.json @@ -0,0 +1,3 @@ +{ + "endpoint": "api/miscellaneous" + } \ No newline at end of file