Closed agsmartwolf closed 1 year ago
Hi @agsmartwolf. The category.id
field is not added by default in the Frontend API permissions - it should be useful to add it to our defaults, we should change that soon. Thanks for the heads up.
Meanwhile, you might find this useful if you want that field (and additional custom fields) to work as well: https://developers.swell.is/guides/opening-content-permissions
You would add something like:
{
"permissions": {
"categories": {
"fields": ["id"]
}
}
}
Hi @rodrigoddalmeida. Thank you for reply. I've tried you said.
I've got the next response:
{
"parent_id": "store name here",
"public": "My public key here",
"date_created": "2022-07-10T18:07:10.902Z",
"scope": "user",
"revoked": false,
"date_updated": "2023-02-23T10:49:27.961Z",
"permissions": {
"categories": {
"fields": [
"id"
],
"input": {
"fields": [
"id"
]
}
}
},
"id": "internal PK here"
}
I've done these actions with all of my public keys. Unfortunately i have the same error:
The error line is id
line in categories.gql.
Are you able to see id
in the Category schema by accessing the playground? (https://<your-store>.swell.store/playground
)
It seems that graphql-codegen
could provide more info on the error, but something is wrong with the package - pluginHelpers
is not found, so maybe there is an issue with peer dependencies or version mismatch for them.
BTW, you don't generally want input
to be set in base model permissions, as they would allow anyone to update that field.
...,
// Not safe
"input": {
"fields": [
"id"
]
}
...
I can see id
in the query I've provided above by accessing the playground. It's working as expected in the playground.
I've also upgraded to the latest versions net packages:
@graphql-codegen/introspection@latest @graphql-codegen/typescript@latest @graphql-codegen/typescript-graphql-request@latest @graphql-codegen/typescript-operations@latest
.
Still the same error.
@rodrigoddalmeida Do you have any thoughts?
@agsmartwolf the playground is a good indicator that your schema is being correctly built and have all fields available.
In that case it seems there might be an issue with how @graphql-codegen/*
packages are interacting with each other. I would suggest doing a full clean up of your node_modules
(and possibly npm's cache) and reinstall your dependencies.
It doesn't help =(
It doesn't help =(
I wish I could give more insight into the error, but additional information seems to be blocked by the missing pluginHelpers.isDetailedError
call, which is a @graphql-codegen
responsibility. Maybe you could monkey-patch your local dependency to extract out the error message there, before the error happens.
If you happen to fix that at some point, let me know.
How can I open permission for the field product.variants.results.active
?
I've tried all of the option I could imagine:
{
"parent_id": "blabla",
"public": "pk",
"date_created": "2022-07-10T18:09:25.254Z",
"scope": "user",
"revoked": false,
"date_updated": "2023-03-08T15:58:17.174Z",
"permissions": {
"categories": {
"fields": [
"id"
]
},
"products": {
"fields": [
":variants.active",
"variants.active",
"variants.results.active",
"options.active"
]
},
"product": {
"fields": [
"active",
"variants.active",
"variants.results.active"
]
},
"products:variants": {
"fields": [
"active",
"variants.active",
"variants.results.active",
"options.active"
]
},
"variant": {
"fields": [
"active"
]
},
"ProductsVariants": {
"fields": [
"active"
]
},
"variants": {
"fields": [
"active"
]
}
},
"id": "blabla"
}
The correct permission for that field is:
{
"products": {
"fields": [
"variants.active"
]
}
}
The reason why you might not see immediate changes to your GraphQL schema after changing permissions is related to caching. One way to force the schema to be refreshed is to request the API with a Cache-control: no-cache
header.
That can be done in the GQL Playground, by setting up its HTTP Headers in the bottom left panel.
I've sent the PUT request with the payload you provided. I have next response:
I tried to send an empty array for the field fields
for other models I've updated before, but it's not updated.
So by the next step, I've set a Cache-Control
header as you said but I still have the problem:
About @graphql-codegen
and categories id
field.
I've re-updated the package and now it shows the error in the next way:
Moreover in playground with cache control is working perfect:
But if I remove the cache control header, remove theid
field - send request, then return id
field and send the request again - an error is returned!
I've sent the PUT request with the payload you provided. I have next response:
I tried to send an empty array for the field
fields
for other models I've updated before, but it's not updated.So by the next step, I've set a
Cache-Control
header as you said but I still have the problem:
It seems you are trying to access active
on the SwellProductVariants
type, which is a Page type and should not contain that field. It should be accessible within results
(SwellProductVariant
type), though:
query {
...
variants {
results {
active
}
}
}
Unfortunately it doesn't work:
OMG!
About products.variants.results.active
- it worked. I have multiple public keys and had changed permissions for another one... So I used the right internal id for the PK I use, and it worked fine.
About codegen I could resolve it too!
I've changed codegen.yml
to the next:
Hi there!
I try to expand categories query with fields "id", "parentId" and "topId":
Everything work but "id" field.
When i'm trying to run "graphql-codegen" there is an error
pluginHelpers.isDetailedError is not a function
. I've checked inswell models
in admin developer panel on the web and all of these fields are presented in model.There is the error only for field
id
.Code is generated with fields
parentId
andtopId
and they are fetched if removeid
field.