GraphQL: Cannot query field "id" on type "searchProducttypeOutput"
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
GraphQL: Cannot query field "id" on type "searchProducttypeOutput"
Laravel framework version: 11.3.1
Aimeos Laravel version: 2024.04
PHP Version: 8.2.17
Environment: Linux
Hello,
I'm getting this error:
Cannot query field "id" on type "searchProducttypeOutput"
Code snippet, used in custom.js in my extension:
I'm using the example from here:
https://aimeos.org/docs/2024.x/admin/graphql/type/
Best regards
Aimeos Laravel version: 2024.04
PHP Version: 8.2.17
Environment: Linux
Hello,
I'm getting this error:
Cannot query field "id" on type "searchProducttypeOutput"
Code snippet, used in custom.js in my extension:
Code: Select all
let filter = {
"==": {"product.type.domain":"product"}
};
const fstr = JSON.stringify(JSON.stringify(filter));
const body = JSON.stringify({'query':
`query {
searchProductTypes(filter: ` + fstr + `) {
id
code
label
}
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
https://aimeos.org/docs/2024.x/admin/graphql/type/
Best regards
Re: GraphQL: Cannot query field "id" on type "searchProducttypeOutput"
Sorry, the documentation wasn't up to date and the correct query in 2024.x+ is:
The "total" property is optional and you should only add it if you need the total number of items matching the query for pagination.
Code: Select all
query {
searchProductTypes(filter: "{\"==\": {\"product.type.domain\":\"product\"}}") {
items {
id
code
label
}
total
}
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: GraphQL: Cannot query field "id" on type "searchProducttypeOutput"
Thank you, I got it working.
For some reason, when adding the filter parameter and using the query with Aimeos.query(), it requires the content of "filter" to be escaped with double slash, not single, don't know why that is, but it works now.
Best regards
For some reason, when adding the filter parameter and using the query with Aimeos.query(), it requires the content of "filter" to be escaped with double slash, not single, don't know why that is, but it works now.
Code: Select all
const result = await Aimeos.query(`query {
searchProductTypes( filter: "{ \\"==\\": { \\"product.type.domain\\": \\"product\\" } }" ) {
items {
id
code
label
}
total
}
}`);
Re: GraphQL: Cannot query field "id" on type "searchProducttypeOutput"
Thanks for the hint, the docs has been adapted accordingly!
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
