Skip to content

Commit

Permalink
#22 lists as input type
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBild committed Dec 20, 2016
1 parent e66c693 commit 32f4d80
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/pouch-graphql/mutations/createUpsertMutationField.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ function createInputTypeFields(typeName, object_types){
const cloned = _.cloneDeep(currentField);
cloned.type = currentField.type.ofType;
result[currentField.name] = cloned;
} else if(currentField.type instanceof GraphQL.GraphQLList
&& currentField.type.ofType
&& currentField.type.ofType instanceof GraphQL.GraphQLScalarType) {
const cloned = _.cloneDeep(currentField);
cloned.args = undefined
cloned.resolve = undefined
cloned.type = currentField.type;
result[currentField.name] = cloned;
} else if(currentField.type instanceof GraphQL.GraphQLScalarType) {
result[currentField.name] = currentField;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-pouch",
"version": "1.1.8",
"version": "1.1.9",
"description": "GraphQL-API runtime on top of PouchDB",
"author": "Mike Bild <[email protected]>",
"license": "MIT",
Expand Down
4 changes: 4 additions & 0 deletions test/integration/graphql/fixtures/mutation-upsert.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation Upsert {
a: upsertPost(input: { id: "test101", title: "title 1", personId: "joe" }) { ...payloadPost }
b: upsertPost(input: { id: "test102", title: "title 2", body: "body 2" personId: "joe" }) { ...payloadPost }
c: upsertPost(input: { id: "test103", title: "title 3", body: "body 3" personId: "joe", tagsIds: ["a1","b1"] }) { ...payloadPost }
}

fragment payloadPost on UpsertPostPayload {
Expand All @@ -10,5 +11,8 @@ fragment payloadPost on UpsertPostPayload {
personId
title
body
tags {
value
}
}
}
20 changes: 18 additions & 2 deletions test/integration/graphql/fixtures/mutation-upsert.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"body": null,
"id": "test101",
"personId": "joe",
"title": "title 1"
"title": "title 1",
"tags": []
}
},
"b": {
Expand All @@ -15,7 +16,22 @@
"body": "body 2",
"id": "test102",
"personId": "joe",
"title": "title 2"
"title": "title 2",
"tags": []
}
},
"c": {
"upsertedPostId": "test103",
"post": {
"body": "body 3",
"id": "test103",
"personId": "joe",
"title": "title 3",
"tags": [{
"value": "A1"
}, {
"value": "B1"
}]
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/integration/graphql/fixtures/relation.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
"name": "John Doe"
}
},
{
"id": "test103",
"body": "body 3",
"title": "title 3",
"personId": "joe",
"person": {
"id": "joe",
"name": "John Doe"
}
},
{
"id": "test2",
"title": "title 2",
Expand Down
10 changes: 10 additions & 0 deletions test/integration/graphql/fixtures/relations.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
"title": "title 2",
"tags": []
},
{
"id": "test103",
"body": "body 3",
"title": "title 3",
"tags": [{
"value": "A1"
}, {
"value": "B1"
}]
},
{
"id": "test2",
"title": "title 2",
Expand Down

0 comments on commit 32f4d80

Please sign in to comment.