"'users' has no argument named 'filter'"
Hello,
I am trying to setup this example https://example.crm.refine.dev/
Using an API through supabase with GraphQL
But i keep getting stuck with an error when updating the settings.tsx file.
message: "'users' has no argument named 'filter'", statusCode: 'validation-failed'
And they payload seems to be passing this
operationName
:
"AdministrationUsers"
query
:
"query AdministrationUsers($filter: UserFilter!, $sorting: [UserSort!], $paging: OffsetPaging!) {\n users(filter: $filter, sorting: $sorting, paging: $paging) {\n nodes {\n id\n name\n jobTitle\n role\n avatarUrl\n }\n totalCount\n }\n}\n"
variables
:
{filter: {}, sorting: [{field: "createdAt", direction: "DESC"}], paging: {limit: 10, offset: 0}}
filter
:
{}
paging
:
{limit: 10, offset: 0}
sorting
:
[{field: "createdAt", direction: "DESC"}]
I don't understand where it is getting the variables from, or how i can modify my code to work.
I am using Hasura for the schema and the table i've setup is called
users
with the columns
name
jobTitle
role
avatarUrl Text
createdAt
Can anyone guide me abit with this? ChatGPT has been helpful, but i feel like i'm stuck at what to look for.
Sorry if i am missing any crucial information, still new to this 🙂
26 Replies
Hi @Konungariket Sverige. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided, it seems like you're trying to use a
filter
argument in your GraphQL query, but your GraphQL schema doesn't recognize it. This is likely because the filter
argument is not defined in your GraphQL schema for the 'users' query.
The error message "'users' has no argument named 'filter'"
is indicating that your GraphQL server doesn't recognize a filter
argument for the 'users' query. This could be because the 'users' query in your GraphQL schema doesn't have a 'filter' argument defined.
The variables you're seeing (filter
, sorting
, paging
) are being passed to your GraphQL query as arguments. These arguments are used to modify the behavior of the query. For example, the filter
argument is typically used to filter the results of the query based on certain criteria.
To resolve this issue, you'll need to update your GraphQL schema to include a 'filter' argument for the 'users' query. The exact way to do this will depend on how your GraphQL server is set up. If you're using Hasura, you might need to define a custom filter input type and use it as an argument in your 'users' query.
Unfortunately, the information extracts provided do not contain specific instructions or code examples for defining arguments in a GraphQL schema with Hasura. I would recommend checking the Hasura documentation or seeking further assistance in the Hasura community.
Please note that refine is a framework for building data-intensive applications and ships with Ant Design System. It offers lots of out-of-the-box functionality for rapid development. If you're using refine with Hasura, make sure to use the correct data provider and follow the appropriate setup instructions.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
ratty-blush•7mo ago
@kapa.ai
But i do not understand where those arguments are coming from. I even removed them from here
export const ADMINISTRATION_USERS_QUERY = gql
query AdministrationUsers(
$filter: UserFilter!
$sorting: [UserSort!]
$paging: OffsetPaging!
) {
users(filter: $filter, sorting: $sorting, paging: $paging) {
nodes {
id
name
jobTitle
role
avatarUrl
}
totalCount
}
}
;
But still it's passed down as variables.Let me check the knowledge base for you. One moment! :books:
----------------------
The arguments you're seeing (
$filter
, $sorting
, $paging
) are variables that are being passed into your GraphQL query. These variables are typically defined and given values elsewhere in your code, outside of the query itself.
In your case, it seems like these variables are still being passed to the query even after you removed them from the query definition. This suggests that the variables are being defined and passed to the query somewhere else in your code.
You'll need to find where these variables are being defined and passed to the AdministrationUsers
query. This could be in a component where the query is being used, or in a function that's calling the query. Once you find where the variables are coming from, you can modify or remove them as needed.
Unfortunately, the information extracts provided do not contain specific code examples or instructions for finding and modifying these variables in your code. I would recommend checking your codebase for instances where the AdministrationUsers
query is being used, and see if the variables are being defined there.
Remember, refine is a framework for building data-intensive applications and ships with Ant Design System. It offers lots of out-of-the-box functionality for rapid development. If you're using refine with Hasura, make sure to use the correct data provider and follow the appropriate setup instructions.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
ratty-blush•7mo ago
@kapa.ai
Well i use the useTable function, might it be from there? And if yes, then where
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, the
useTable
hook could be the source of these variables. The useTable
hook is used to fetch data and it accepts an object with various options, including queryOptions
which could be where your filter
, sorting
, and paging
variables are coming from.
Here's a basic usage of useTable
hook from the extracts:
In the context of refine, the useTable
hook is used to fetch and manage table data. It uses the useList
hook under the hood to fetch data and provides several methods and properties that you can use to retrieve the table headers and rows and add other useful table features.
If you're using the useTable
hook in your code, you'll need to check where you're calling this hook and what options you're passing to it. The filter
, sorting
, and paging
variables could be defined in these options.
Unfortunately, the information extracts provided do not contain specific code examples or instructions for finding and modifying these variables in your code. I would recommend checking your codebase for instances where the useTable
hook is being used, and see if the variables are being defined there.
For more information on how to use the useTable
hook with refine, you can refer to the refine documentation (https://refine.dev/docs/data/hooks/use-table/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
ratty-blush•7mo ago
@kapa.ai
Well i think i am passing this values?
const UsersTable = () => {
const { tableProps, filters } = useTable<
GetFieldsFromList<AdministrationUsersQuery>
>({
resource: "users",
sorters: {
initial: [
{
field: "createdAt",
order: "desc",
},
],
},
filters: {
initial: [
{
field: "jobTitle",
value: "",
operator: "contains",
},
{
field: "name",
value: "",
operator: "contains",
},
{
field: "status",
value: undefined,
operator: "in",
},
],
},
meta: {
gqlQuery: ADMINISTRATION_USERS_QUERY,
},
});
But even when i removed them, they are still passed as variables.
That's why i got so confused as to where the variables are actually coming from.
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, you're correct. The
useTable
hook is where the filter
, sorting
, and paging
variables are coming from. In your code, you're passing an object to useTable
that includes sorters
and filters
properties. These properties are used to initialize the sorting and filtering behavior of your table.
However, if you've removed these properties and they're still being passed as variables, it's possible that there's another part of your code that's also using the useTable
hook and passing these variables.
Another possibility is that the changes you made haven't been properly applied due to a caching issue or a problem with your development server. If you haven't already, try restarting your development server and clearing any caches to ensure that your changes are being applied.
If you're still having trouble, I would recommend checking the rest of your codebase for any other instances where the useTable
hook is being used. Also, make sure that the useTable
hook isn't being called with these variables in any parent components or higher-order components.
For more information on how to use the useTable
hook with refine, you can refer to the refine documentation (https://refine.dev/docs/data/hooks/use-table/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
ratty-blush•7mo ago
@kapa.ai could it be something at the backend in Hasura?
'users' has no argument named 'filter'
Error (status code: validation-failed)
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, the error message
"'users' has no argument named 'filter'"
is indicating that your GraphQL server (Hasura in this case) doesn't recognize a filter
argument for the 'users' query. This could be because the 'users' query in your GraphQL schema doesn't have a 'filter' argument defined.
In Hasura, you can define arguments for your queries using the Hasura console or the Hasura CLI. If you want to add a 'filter' argument to your 'users' query, you'll need to modify your GraphQL schema in Hasura.
Unfortunately, the information extracts provided do not contain specific instructions or code examples for defining arguments in a GraphQL schema with Hasura. I would recommend checking the Hasura documentation (https://hasura.io/docs/latest/graphql/core/databases/postgres/schema/relationships.html) or seeking further assistance in the Hasura community.
Remember, refine is a framework for building data-intensive applications and ships with Ant Design System. It offers lots of out-of-the-box functionality for rapid development. If you're using refine with Hasura, make sure to use the correct data provider and follow the appropriate setup instructions. For example, refine provides a data provider for APIs powered with Hasura, which you can install and use in your refine application like so:
You can find more information on using data providers in a refine application in the refine documentation (https://refine.dev/docs/api-reference/core/providers/data-provider/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
ratty-blush•7mo ago
@kapa.ai
Hasura expect these variables
$where, $order_by, $limit, and $offset
But the code is providing filter, paging, sorting
Is it possible to change the useTable to provide that instead? Or do i need to update it in their auto-genereated schema, which seems impossible 😂