Getting the following error trying to execute the following query:
mutation{
updateActiveOffer(id: "5d7d7476c9bb8714baa52d5a", data : { quantity:2 }){
quantity
offer{
name
}
}
}
"errors": [
{
"message": "You do not have access to this resource",
"name": "AccessDeniedError",
"time_thrown": "2019-09-15T01:39:39.829Z",
"data": {
"type": "mutation",
"target": "updateActivedOffer"
},
"path": [
"updateActivedOffer"
],
"uid": "ck0kbaoqd00021m3a900r0j1w"
}
],
"data": {
"updateActivedOffer": null
}
}
I've removed any authStrategy and here is the list's configaration-
exports.ActiveOffers = {
fields: {
offer: {
type: Relationship,
ref: 'Offer',
many: false
},
assosciatedUser: { type: Relationship, ref: 'User', many: false },
// expires: { type: DateTime },
quantity: { type: Integer },
slug: {
type: Slug,
from: 'offer'
},
},
access: {
create: true,
read: true,
update: true,
delete: true,
},
labelResolver: async (item) => {
return `${item.offer} <${item.quantity}>`
},
}
馃 Everything in your code looks ok. Can you also provide the setup for the Offer list which you're querying via the <ActiveOffers>.offer field.
@jesstelford Here you go-
exports.Offers = {
fields: {
name: {
type: Text
},
item: {
type: Relationship,
ref: 'Product',
many: false
},
drink: {
type: Relationship,
ref: 'Recipe',
many: false
},
slug: {
type: Slug,
from: 'name'
},
},
labelResolver: item => `${item.name}`,
access: {
create: true,
read: true,
update: true,
delete: true,
},
}
@Nakzz Are you getting this error with no authentication strategy? I attempted to replicate what you have here and it appears to be working for me.
I get "You do not have access to this resource" when I enter an incorrect Id. I'd check to make sure you are using the right Id for an ActiveOffer.
@jesstelford I did find what I think is an un-related error. Or maybe it is not an error. This mutation doesn't work if I don't include a string for the slug field.
mutation {
updateActiveOffer(id: "5d802f968b58725e5a0de3da", data: { quantity: 3, slug: "need-string" } ){
quantity
}
}
It should be resolving the slug field from the offer field which is a Relationship. I'm guessing this fails because there is no string representation for the offer? Perhaps you are not allowed to use 'from' on Relationships?
The action here should be to capture this and report a better error message or to resolve the relationship id as a string?
I'm guessing this fails because there is no string representation for the offer? Perhaps you are not allowed to use 'from' on Relationships?
This is correct; the Slug.from setting should point to a field which has a text value. We could do better at attempting to resolve that and throw a more useful error.
As it stands, the configuration for ActiveOffers.slug should probably be removed.
Thanks! I'll make an issue for a better error message and close this one. @Nakzz Thanks for your help in reporting issues recently. I hope this resolves it for you and you're able to get your project running.
If you need more help with this, or other general questions jump onto the community slack channel: http://community.keystonejs.com I'm usually hanging around there and will be able to offer more help.
@MadeByMike I am trying to join the slack channel but putting my email in the link you gave doesn't do anything on my end. I've tried different emails- any idea how I can get access to the slack channel?
@Nakzz It looks like it might be playing funny with some ad blockers. Disabling mine got it to work. In the short term try that. In the long term I'll look for a service that works with ad blockers.
Message me if you have trouble and I'll add you manually