stormy-gold
stormy-gold•6mo ago

"'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
kapa.ai
kapa.ai•6mo ago
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: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo 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.
kapa.ai
kapa.ai•6mo ago
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: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo ago
@kapa.ai Well i use the useTable function, might it be from there? And if yes, then where
kapa.ai
kapa.ai•6mo ago
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:
import { useTable } from "@refinedev/core";
useTable({
queryOptions: {
retry: 3,
},
});
import { useTable } from "@refinedev/core";
useTable({
queryOptions: {
retry: 3,
},
});
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: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo 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.
kapa.ai
kapa.ai•6mo ago
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: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo ago
@kapa.ai could it be something at the backend in Hasura? 'users' has no argument named 'filter' Error (status code: validation-failed)
kapa.ai
kapa.ai•6mo ago
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:
npm install @refinedev/hasura
npm install @refinedev/hasura
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: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo 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 😂
kapa.ai
kapa.ai•6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Yes, you can modify the variables passed to the useTable hook to match what your Hasura GraphQL server expects. The useTable hook accepts an object with various options, including queryOptions which is where your filter, sorting, and paging variables are coming from. In your case, you would need to replace filter, sorting, and paging with $where, $order_by, $limit, and $offset respectively. However, you would also need to ensure that the values you pass for these variables are in the correct format expected by your Hasura server. Here's an example of how you might modify your useTable call:
const { tableProps, filters } = useTable({
resource: "users",
queryOptions: {
variables: {
$where: /* your where condition */,
$order_by: /* your order by condition */,
$limit: /* your limit */,
$offset: /* your offset */,
},
},
meta: {
gqlQuery: ADMINISTRATION_USERS_QUERY,
},
});
const { tableProps, filters } = useTable({
resource: "users",
queryOptions: {
variables: {
$where: /* your where condition */,
$order_by: /* your order by condition */,
$limit: /* your limit */,
$offset: /* your offset */,
},
},
meta: {
gqlQuery: ADMINISTRATION_USERS_QUERY,
},
});
Please note that you'll need to replace /* your where condition */, /* your order by condition */, /* your limit */, and /* your offset */ with the actual conditions and values you want to use. Unfortunately, the information extracts provided do not contain specific code examples or instructions for defining these variables in your code. I would recommend checking the refine documentation (https://refine.dev/docs/data/hooks/use-table/) for more information on how to use the useTable hook. As for updating the auto-generated schema in Hasura, it's generally not recommended to manually modify an auto-generated schema as it can lead to inconsistencies and errors. Instead, you should define your schema using the Hasura console or the Hasura CLI, and let Hasura generate the schema for you. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo ago
@kapa.ai Thank you for the example. But it's still not working, same error Wouldn't the variable say the same as you just described, but still it says filter, sorting and paging. {,…} operationName : "AdministrationUsers" query : "query AdministrationUsers($where: users_bool_exp, $order_by: [users_order_by!], $limit: Int, $offset: Int) {\n users(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {\n nodes {\n id\n name\n jobTitle\n role\n avatarUrl\n }\n totalCount\n }\n}\n" variables : {filter: {}, sorting: [], paging: {limit: 10, offset: 0}}
kapa.ai
kapa.ai•6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The issue seems to be that the variables in your GraphQL query ($where, $order_by, $limit, and $offset) are not matching the variables that are being passed in (filter, sorting, and paging). In your useTable hook, you're defining queryOptions with variables that match what your Hasura server expects ($where, $order_by, $limit, and $offset). However, the actual variables being passed in are still filter, sorting, and paging. This mismatch is likely causing the error you're seeing. The variables in your GraphQL query need to match the variables that are being passed in. Here's an example of how you might modify your useTable call:
const {{ tableProps, filters }} = useTable({{
resource: "users",
queryOptions: {{
variables: {{
$where: /* your where condition */,
$order_by: /* your order by condition */,
$limit: /* your limit */,
$offset: /* your offset */,
}},
}},
meta: {{
gqlQuery: ADMINISTRATION_USERS_QUERY,
}},
}});
const {{ tableProps, filters }} = useTable({{
resource: "users",
queryOptions: {{
variables: {{
$where: /* your where condition */,
$order_by: /* your order by condition */,
$limit: /* your limit */,
$offset: /* your offset */,
}},
}},
meta: {{
gqlQuery: ADMINISTRATION_USERS_QUERY,
}},
}});
In this example, the variables object in queryOptions is defining the variables that will be passed to your GraphQL query. You'll need to replace /* your where condition */, /* your order by condition */, /* your limit */, and /* your offset */ with the actual conditions and values you want to use. Unfortunately, the information extracts provided do not contain specific code examples or instructions for defining these variables in your code. I would recommend checking the refine documentation (https://refine.dev/docs/data/hooks/use-table/) for more information on how to use the useTable hook. If you're still having trouble, it might be helpful to seek further assistance in the refine community or from a developer familiar with refine and Hasura. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo ago
@kapa.ai That was the same example, it's still not working, do you have any other examples? And like i said previously, should not your example have changed the variables that was displayed? They are still the same.
kapa.ai
kapa.ai•6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I apologize for the confusion. The useTable hook in refine uses the filter, sorting, and paging variables by default. These variables are used internally by refine to handle filtering, sorting, and pagination of the table data. If your GraphQL server expects different variables ($where, $order_by, $limit, and $offset), you might need to create a custom data provider to translate between the variables used by refine and the variables expected by your server. Creating a custom data provider involves implementing the DataProvider interface provided by refine. This interface includes methods for each of the CRUD operations (Create, Read, Update, Delete), as well as methods for handling sorting, filtering, and pagination. Here's a basic example of a custom data provider:
import { DataProvider } from "@refinedev/core";

const customDataProvider: DataProvider = {
getList: ({ resource, pagination, sort, filter }) => {
// Translate refine variables to Hasura variables
const $where = filter;
const $order_by = sort;
const $limit = pagination.pageSize;
const $offset = (pagination.current - 1) * pagination.pageSize;

// Call your GraphQL query with the translated variables
// ...
},
// Implement other methods...
};

export default customDataProvider;
import { DataProvider } from "@refinedev/core";

const customDataProvider: DataProvider = {
getList: ({ resource, pagination, sort, filter }) => {
// Translate refine variables to Hasura variables
const $where = filter;
const $order_by = sort;
const $limit = pagination.pageSize;
const $offset = (pagination.current - 1) * pagination.pageSize;

// Call your GraphQL query with the translated variables
// ...
},
// Implement other methods...
};

export default customDataProvider;
In this example, the getList method is translating the filter, sort, and pagination variables from refine into the $where, $order_by, $limit, and $offset variables expected by Hasura. Please note that this is a simplified example and you'll need to implement the translation logic to match your specific needs. Also, you'll need to implement the other methods of the DataProvider interface (getOne, getMany, create, update, updateMany, delete, deleteMany) in a similar way. Unfortunately, the information extracts provided do not contain specific code examples or instructions for creating a custom data provider. I would recommend checking the refine documentation (https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider/) for more information on how to create a custom data provider. If you're still having trouble, it might be helpful to seek further assistance in the refine community or from a developer familiar with refine and Hasura. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold
stormy-gold•6mo ago
@kapa.ai But i think i most be doing something wrong, earlier questions about this, the answer seems to be "It's so easy" And in the https://api.crm.refine.dev/graphql the arguments align with the frontend. But not when using Hasuro and Supabase, what would i use instead? Would not seem to be so complicated to just use the example project and update the API information, what's up with all these custom things, i just think i am missing something and making it way too complicated.
kapa.ai
kapa.ai•6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I understand your frustration. The process can seem complicated when the variables used by the front-end (refine) and the back-end (Hasura or Supabase) do not align. The useTable hook in refine uses filter, sorting, and paging variables by default. These variables are used internally by refine to handle filtering, sorting, and pagination of the table data. On the other hand, Hasura and Supabase use different variables ($where, $order_by, $limit, and $offset) for their GraphQL queries. This discrepancy is what's causing the issue. The simplest solution would be to align the variables used by your front-end and back-end. This would involve updating your GraphQL server to accept filter, sorting, and paging variables, or updating your refine application to use $where, $order_by, $limit, and $offset variables. However, this might not be feasible depending on your specific use case. Another solution is to create a custom data provider in refine. This would involve implementing the DataProvider interface provided by refine and translating between the variables used by refine and the variables expected by your GraphQL server. This is a more complex solution, but it gives you more control over how your data is fetched and managed. Unfortunately, the information extracts provided do not contain specific code examples or instructions for creating a custom data provider. I would recommend checking the refine documentation (https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider/) for more information on how to create a custom data provider. If you're still having trouble, it might be helpful to seek further assistance in the refine community or from a developer familiar with refine and Hasura or Supabase. They might be able to provide more specific guidance based on your exact setup and requirements. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai•6mo ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below