|
@@ -30,7 +30,7 @@ export const categoryApi = createApi({
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`}),
|
|
`}),
|
|
- providesTags: (result, error, arg) => {
|
|
|
|
|
|
+ providesTags: (result) => {
|
|
return result
|
|
return result
|
|
? [...result.CategoryFind.map(obj => ({ type: 'Category', _id: obj._id })), 'Category']
|
|
? [...result.CategoryFind.map(obj => ({ type: 'Category', _id: obj._id })), 'Category']
|
|
: ['Category'];
|
|
: ['Category'];
|
|
@@ -52,7 +52,7 @@ export const categoryApi = createApi({
|
|
variables: params
|
|
variables: params
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- providesTags: (result, error, arg) => {
|
|
|
|
|
|
+ providesTags: (result) => {
|
|
return result
|
|
return result
|
|
? [...result.CategoryFind.map(obj => ({ type: 'Category', _id: obj._id })), 'Category']
|
|
? [...result.CategoryFind.map(obj => ({ type: 'Category', _id: obj._id })), 'Category']
|
|
: ['Category'];
|
|
: ['Category'];
|
|
@@ -70,9 +70,6 @@ export const categoryApi = createApi({
|
|
},
|
|
},
|
|
providesTags: ['CategoryCount'],
|
|
providesTags: ['CategoryCount'],
|
|
}),
|
|
}),
|
|
- /*forceRefetch(arg) {
|
|
|
|
- return JSON.stringify(arg.currentArg) !== JSON.stringify(arg.previousArg);
|
|
|
|
- },*/
|
|
|
|
getCategoryById: builder.query({
|
|
getCategoryById: builder.query({
|
|
query: (_id) => ({
|
|
query: (_id) => ({
|
|
document: gql`
|
|
document: gql`
|
|
@@ -89,7 +86,7 @@ export const categoryApi = createApi({
|
|
`,
|
|
`,
|
|
variables: { q: JSON.stringify([{ _id }]) }
|
|
variables: { q: JSON.stringify([{ _id }]) }
|
|
}),
|
|
}),
|
|
- providesTags: (result, error, arg) => {
|
|
|
|
|
|
+ providesTags: (result) => {
|
|
return result
|
|
return result
|
|
? [{ type: 'Category', _id: result.CategoryFindOne._id }, 'Category']
|
|
? [{ type: 'Category', _id: result.CategoryFindOne._id }, 'Category']
|
|
: ['Category'];
|
|
: ['Category'];
|
|
@@ -110,10 +107,10 @@ export const categoryApi = createApi({
|
|
variables: { category: { ...category } }
|
|
variables: { category: { ...category } }
|
|
}
|
|
}
|
|
),
|
|
),
|
|
- transformResponse: (response, meta, arg) => {
|
|
|
|
|
|
+ transformResponse: (response) => {
|
|
return response;
|
|
return response;
|
|
},
|
|
},
|
|
- transformErrorResponse: (response, meta, arg) => {
|
|
|
|
|
|
+ transformErrorResponse: (response) => {
|
|
return response;
|
|
return response;
|
|
},
|
|
},
|
|
invalidatesTags: (result, error, arg) => {
|
|
invalidatesTags: (result, error, arg) => {
|
|
@@ -126,14 +123,5 @@ export const categoryApi = createApi({
|
|
}),
|
|
}),
|
|
})
|
|
})
|
|
|
|
|
|
-/*export const categoryApi = categoryApiInt.enhanceEndpoints({
|
|
|
|
- endpoints: {
|
|
|
|
- getCategoriesCount(endpoint) {
|
|
|
|
- endpoint.refetchOnMountOrArgChange = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-})*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
export const { useGetRootCategoriesQuery, useGetCategoryByIdQuery, useGetCategoriesQuery, useGetCategoriesCountQuery, useSaveCategoryMutation } = categoryApi;
|
|
export const { useGetRootCategoriesQuery, useGetCategoryByIdQuery, useGetCategoriesQuery, useGetCategoriesCountQuery, useSaveCategoryMutation } = categoryApi;
|
|
|
|
|