-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] GraphQL - Mutations #1650
Conversation
Apologies if I'm overstepping but I manually merged this into a Strapi test project and everything seems to be working nicely except the GraphQL Playground. The playground doesn't show a cursor and settings are not being loaded properly/if at all (e.g. applying the light theme). A quick patch can be found: graphql/graphql-playground#790 and that fixes the cursor. |
Bug found, I would post into issues but I'm not sure what the rules are for creating issues for PR's. Nevertheless, see below: When performing a mutation to either create or update, the type "Decimal" will fail and expect a string.
item {
price: Decimal
}
item {
price: String
} What's happening? The mutations implementation isn't handling Decimals. This isn't an issue as the GraphQL standards don't support Decimals. Debate: Should Strapi implement the decimal type or convert decimals into floats for the GraphQL? |
Bug 2: Mutation Query: mutation {
createItem(input: {
data: {
name: "Orange",
description: "A sweet and tasty fruit.",
price: 3.00,
inStock: true,
}
}) {
item {
name
description
price
inStock
}
}
} Return JSON: {
"data": {
"createItem": null
},
"errors": [
{
"message": " not a valid Decimal128 string",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createItem"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: not a valid Decimal128 string",
" at Function.Decimal128.fromString (/home/jason/LittleMenuStrapi/node_modules/mongodb-core/node_modules/bson/lib/bson/decimal128.js:252:11)",
" at Decimal128.cast (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/schema/decimal128.js:122:27)",
" at Decimal128.SchemaType.getDefault (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/schematype.js:702:25)",
" at $__applyDefaults (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/document.js:309:22)",
" at model.Document (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/document.js:104:3)",
" at model.Model (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/model.js:72:12)",
" at new model (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/model.js:4286:13)",
" at toExecute.push.callback (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/model.js:2491:22)",
" at /home/jason/LittleMenuStrapi/node_modules/async/internal/parallel.js:31:39",
" at eachOfArrayLike (/home/jason/LittleMenuStrapi/node_modules/async/eachOf.js:65:9)",
" at exports.default (/home/jason/LittleMenuStrapi/node_modules/async/eachOf.js:9:5)",
" at _parallel (/home/jason/LittleMenuStrapi/node_modules/async/internal/parallel.js:30:5)",
" at parallelLimit (/home/jason/LittleMenuStrapi/node_modules/async/parallel.js:88:26)",
" at utils.promiseOrCallback.cb (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/model.js:2501:5)",
" at Promise (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/utils.js:246:5)",
" at new Promise (<anonymous>)",
" at Object.promiseOrCallback (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/utils.js:245:10)",
" at Function.create (/home/jason/LittleMenuStrapi/node_modules/mongoose/lib/model.js:2462:16)",
" at Object.add (/home/jason/LittleMenuStrapi/api/item/services/Item.js:83:30)",
" at create (/home/jason/LittleMenuStrapi/api/item/controllers/Item.js:56:33)",
" at resolver (/home/jason/LittleMenuStrapi/plugins/graphql/services/Mutation.js:136:16)",
" at /home/jason/LittleMenuStrapi/plugins/graphql/services/Mutation.js:218:41"
]
}
}
}
]
} |
@TokenChingy The Bug #2 is due to the version of MongoDB. Please make sure you're using the latest version (>3.6). I don't have time to improve the changes made to this PR. I would love to see you make the new updates to be able to merge it 😍 |
@Aurelsicoko interesting. Will look into my version, might be due to outdated sources for this DigitalOcean instance I'm running this on. Will do, Am taking it through it's paces and will patch up any bugs I find. Will also implement somethings. Does Strapi want to support the Decimal type? |
@TokenChingy Yes, we should certainly create a Scalar type to handle Decimal 👍 |
@Aurelsicoko it's definetly not my MongoDB version, just did a fresh server install: Ubuntu 18.04LTS Also went through and check to make sure the MongoDB Driver was up-to-date, it is. Any ideas? EDIT: Referencing the Issue #1859 |
@Aurelsicoko I'm working on fixing this bug and also bringing inline the Decimal scalar type, but I have realised that this branch is behind and doesn't have the aggregations/groupings functions. I've merged these in and would like to be able to commit them to this PR, can I get permission? |
@TokenChingy Yes, you can! This has to be done anyway 👍 |
So I’ve created a new PR merging this with aggregations. I’ve also fixed decimals #1924. |
@TokenChingy Thank you, we have to keep in mind to close this PR when the other will be merged... |
My PR is a: 🚀 New feature
Main update on the: Plugin GraphQL
The title is pretty clear, we're going to support mutations in the next couple days/weeks 🎉