wise-white
wise-white7mo ago

nestjs-query wrong graphql format

Im trying to use the MuiInferencer together with NestJS-Query the Format that is correct and generated by NestJS-Query is following query { players { pageInfo { hasNextPage hasPreviousPage startCursor endCursor } edges { node { id firstName lastName created } cursor } } } But the query that Refine generates looks like the following query { players { nodes { id, firstName }, totalCount } } Note that "nodes" does not exist
14 Replies
kapa.ai
kapa.ai7mo ago
Hi @justin99b. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Refine's Inferencer tool is designed to help developers quickly generate CRUD (create, read, update, delete) pages for their data model. It analyzes your data model based on the resource scheme and automatically creates the pages with the required forms and tables for CRUD operations. However, it might not always generate the exact query structure that your specific API or backend service expects. In your case, it seems like the query generated by Refine's Inferencer does not match the structure expected by your NestJS-Query GraphQL API. The Inferencer is generating a query with "nodes", but your API expects a different structure. Unfortunately, based on the information provided in the extracts, there's no direct way to customize the query generated by the Inferencer. The Inferencer is primarily used to generate sample codes for your views and infer the fields of the data provider's response. If the Inferencer doesn't generate the correct query, you might need to write those components and queries yourself. As one of the community members mentioned in the Discord thread, the Inferencer is meant to save you some time during development, but it might not always produce production-ready code. For more information about the Inferencer and how to use it, you can check out the official documentation (https://refine.dev/docs/api-reference/mui/components/inferencer/). For examples of how to use the NestJS-Query data provider with Refine, you can check out this example in the documentation (https://refine.dev/docs/examples/data-provider/nestjs-query/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@337253340121399296> kapa.ai is still learning and improving, please let us know how it did by reacting below
deep-jade
deep-jade7mo ago
It doesn’t support relay format. You can use offset pagination for your dtos
wise-white
wise-white7mo ago
I just followed the official NestJS-Query Documentation 😄 i dont even know what a relay format is Thats what my Dto looks like
@ObjectType('Player')
export class PlayerDto {
@IDField(() => ID)
id!: number;

@FilterableField()
firstName!: string;

@FilterableField()
lastName!: string;

@Field(() => GraphQLISODateTime)
created!: Date;
}
@ObjectType('Player')
export class PlayerDto {
@IDField(() => ID)
id!: number;

@FilterableField()
firstName!: string;

@FilterableField()
lastName!: string;

@Field(() => GraphQLISODateTime)
created!: Date;
}
The only thing i can imagine is the FIlterableField
deep-jade
deep-jade7mo ago
Check the place where you define ‘resolvers’ array. You can import ‘PaginationMode’ enum. It should have .offset option
wise-white
wise-white7mo ago
Ah perfect! Setting it to offset now contains nodes and i had to enable enableTotalCount The Query now executes inside the playground but Refine still thows an error Actually i think the requests fails
No description
wise-white
wise-white7mo ago
No description
No description
wise-white
wise-white7mo ago
No description
wise-white
wise-white7mo ago
... We all love CORS dont we 🙂 Thanks for your help it works now! @kapa.ai How can i use Inferencer to not only edit or show but also to delete a entry
kapa.ai
kapa.ai7mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The Inferencer tool in Refine is primarily used to generate CRUD (Create, Read, Update, Delete) pages based on your data model. However, it doesn't directly handle the deletion of entries. The deletion of entries is typically handled by the data provider you're using with Refine. To enable deletion of entries, you need to specify canDelete: true in the meta property of your resource when defining your resources in the <Refine /> component. Here's an example from the extracts:
<Refine
resources={[
{
name: "posts",
list: "/posts",
create: "/posts/create",
edit: "/posts/edit/:id",
show: "/posts/show/:id",
meta: {
canDelete: true,
},
},
]}
>
<Refine
resources={[
{
name: "posts",
list: "/posts",
create: "/posts/create",
edit: "/posts/edit/:id",
show: "/posts/show/:id",
meta: {
canDelete: true,
},
},
]}
>
In this example, the canDelete: true property enables the deletion of "posts" entries. When you navigate to the detail view of a post, you should see a delete button if your data provider supports the delete operation. Remember, the actual deletion operation is performed by your data provider, not the Inferencer. The Inferencer just generates the pages and UI elements based on your data model. For more information about how to use the Inferencer, you can check out the official documentation (https://refine.dev/docs/api-reference/core/components/inferencer/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@337253340121399296> kapa.ai is still learning and improving, please let us know how it did by reacting below
wise-white
wise-white7mo ago
It works now but there are some queries triggered when loading the page again with a wrong query Now it seems like the resource name is missing in the query
No description
deep-jade
deep-jade7mo ago
Hello @justin99b suggested way to use inferencer is to copy/paste the generated code you see in UI and fine tune yourself. It gives a good starter but may not work perfectly.
wise-white
wise-white7mo ago
Alright gonna tes that. Thanks alot for your help! Its really usefull to have the generated code
More Posts
Refine without react as a Client library for Server to Server communicationIs it possible to Access resources, live Providers and so on via an API Client? So you can make use Hey guys 🙂Hey guys 🙂 I discovered refine a few weeks ago and had a hard time understanding what it actually iIs there anyway to use different layouts for different routes?I am using Refine with Next (app router). I know you can define your own layouts, but is it possibleHow to type useOne with typings for select propHow can i call useOne with typings for select prop so i can always extract the propertie data.data'filters' does not exist in type 'UseTableProps<BaseRecord, HttpError, any>'. Did you mean to writeWhen using headless mode, I want to use client side filtering as I run into rate limiting issues frouseCustom get request not sending meta populate params (Strapi)Hi, i'm trying to make a request to get a resource with a relation populated trough the useCustom hoResource without initial recordsHi there. I've the problem when trying to use AntdListInferencer to display the resource without recRefine example setupHello there, I've been in search for low-code / no-code open source dashboards and I stumbled upon ris there any quick way to convert example "app-crm" to support next.js?I want to customize app-crm example, but also I want to use next.js framework. Is there a quick way Unexpected end of JSON input``` check: async () => { const user: IUser = JSON.parse(localStorage.getItem(ELocalStorage.USER)