How to pass orderBy value as parameter to GraphQL query? I tried as String but this will get you error something similar as:
âmessageâ: âArgument âorderByâ on Field âallDownloadsâ has an invalid value ("name_ASC"). Expected type â[DownloadModelOrderBy]â.â,
Currently I have this, but this still gives me query error. I canât figure what do I need to pass as sortOrder value to match Expected type [DownloadModelOrderBy]
?
export async function getDownloadsByCategoryId(
categoryId,
sortOrder,
skip,
locale,
preview
) {
const data = await fetchAPI(
`
query DownloadsByCategoryId(
$categoryId: ItemId = "",
$sort: [DownloadModelOrderBy],
$skip: IntType!,
$locale: SiteLocale = ${process.env.DEFAULT_SITE_LOCALE}
) {
allDownloads(
first: 100,
skip: $skip,
locale: $locale,
filter: {category: {eq: $categoryId}},
orderBy: $sort
) {
__typename
id
name
language
version
attribute1
attribute2
description
fileType
changeLog
seo: _seoMetaTags {
...metaTagsFragment
}
asset {
url
size
filename
mimeType
}
}
}
${metaTagsFragment}
`,
{
preview,
variables: {
locale: normalizeLanguages(locale),
categoryId: categoryId,
skip: skip,
sort: sortOrder,
}
},
)
return data;
}
but I can figure what value to pass into the function to fit [DownloadModelOrderBy]
?