Skip to content

Commit

Permalink
add example mutation, insertArtist, in fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
hallettj committed Mar 19, 2024
1 parent 6af42b6 commit a092d72
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions fixtures/connector/chinook/native_queries/hello.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: hello
description: Example of a read-only native query
objectTypes:
- name: HelloResult
fields:
Expand Down
16 changes: 16 additions & 0 deletions fixtures/connector/chinook/native_queries/insert_artist.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: insertArtist
description: Example of a database update using a native query
objectTypes:
- name: InsertArtist
fields:
- name: ok
type: !scalar int
- name: n
type: !scalar int
resultType: !object InsertArtist
# TODO: implement arguments instead of hard-coding inputs
command:
insert: "Artist"
documents:
- ArtistId: 1001
- Name: Regina Spektor
54 changes: 54 additions & 0 deletions fixtures/ddn/subgraphs/chinook/commands/InsertArtist.hml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
kind: Command
version: v1
definition:
name: insertArtist
description: Example of a database update using a native query
outputType: InsertArtist
arguments: []
source:
dataConnectorName: mongodb
dataConnectorCommand:
procedure: insertArtist
typeMapping:
InsertArtist:
fieldMapping:
ok: { column: ok }
n: { column: n }
graphql:
rootFieldName: insertArtist
rootFieldKind: Mutation

---
kind: CommandPermissions
version: v1
definition:
commandName: insertArtist
permissions:
- role: admin
allowExecution: true

---
kind: ObjectType
version: v1
definition:
name: InsertArtist
graphql:
typeName: InsertArtist
fields:
- name: ok
type: Int!
- name: n
type: Int!

---
kind: TypePermissions
version: v1
definition:
typeName: InsertArtist
permissions:
- role: admin
output:
allowedFields:
- ok
- n

14 changes: 13 additions & 1 deletion fixtures/ddn/subgraphs/chinook/dataconnectors/mongodb.hml
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,12 @@ definition:
type: { type: named, name: Int }
readOnly:
type: { type: named, name: Boolean }
InsertArtist:
fields:
ok:
type: { type: named, name: Int }
n:
type: { type: named, name: Int }
collections:
- name: Album
arguments: {}
Expand Down Expand Up @@ -1002,10 +1008,16 @@ definition:
foreign_keys: {}
functions:
- name: hello
description: Example of a read-only native query
result_type: { type: named, name: HelloResult }
arguments: {}
command: { hello: 1 }
procedures: []
procedures:
- name: insertArtist
description: Example of a database update using a native query
result_type: { type: named, name: InsertArtist }
arguments: {}
command: { insert: Artist, documents: [{ ArtistId: 1001, Name: Regina Spektor }] }
capabilities:
version: ^0.1.0
capabilities:
Expand Down

0 comments on commit a092d72

Please sign in to comment.