Skip to content

Commit 454d4cf

Browse files
authored
Merge pull request #50 from rtk-incubator/next
fix(imports): move from rtk-query to redux-toolkit (#49)
2 parents 830302f + 7dad2b5 commit 454d4cf

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@babel/core": "^7.12.10",
2525
"@babel/preset-env": "^7.12.11",
2626
"@babel/preset-typescript": "^7.12.7",
27-
"@rtk-incubator/rtk-query": "^0.2.0",
27+
"@reduxjs/toolkit": "^1.6.0-alpha.2",
2828
"@types/commander": "^2.12.2",
2929
"@types/glob-to-regexp": "^0.4.0",
3030
"@types/jest": "^26.0.20",

src/generate.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import { createQuestionToken, keywordType } from 'oazapfts/lib/codegen/tscodegen
1111
import { OpenAPIV3 } from 'openapi-types';
1212
import { generateReactHooks } from './generators/react-hooks';
1313
import { GenerationOptions, OperationDefinition } from './types';
14-
import { capitalize, getOperationDefinitions, getV3Doc, isQuery, MESSAGES } from './utils';
15-
import { removeUndefined } from './utils/removeUndefined';
14+
import { capitalize, getOperationDefinitions, getV3Doc, isQuery, MESSAGES, removeUndefined } from './utils';
1615
import {
1716
generateCreateApiCall,
1817
generateEndpointDefinition,
@@ -140,16 +139,16 @@ export async function generateApi(
140139
ts.EmitHint.Unspecified,
141140
factory.createSourceFile(
142141
[
143-
// If hooks are specified, we need to import them from the react entry point in RTKQ >= 0.3
142+
// If hooks are specified, we need to import them from the react entry point
144143
...(hooks
145144
? [
146-
generateImportNode('@rtk-incubator/rtk-query/react', {
145+
generateImportNode('@reduxjs/toolkit/query/react', {
147146
createApi: 'createApi',
148147
}),
149148
]
150149
: []),
151150
...(hasBasePackageImports
152-
? [generateImportNode('@rtk-incubator/rtk-query', getBasePackageImportsFromOptions())]
151+
? [generateImportNode('@reduxjs/toolkit/query', getBasePackageImportsFromOptions())]
153152
: []),
154153
...(customBaseQueryNode ? [customBaseQueryNode] : []),
155154
generateCreateApiCall({

test/__snapshots__/cli.test.ts.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`CLI options testing should accept a valid url as the target swagger file and generate a client 1`] = `
4-
import { createApi, fetchBaseQuery } from "@rtk-incubator/rtk-query";
4+
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query";
55
export const api = createApi({
66
baseQuery: fetchBaseQuery({ baseUrl: "/api/v3" }),
77
tagTypes: [],
@@ -270,7 +270,7 @@ export type User = {
270270
`;
271271

272272
exports[`CLI options testing should create a file when --file is specified 1`] = `
273-
import { createApi, fetchBaseQuery } from '@rtk-incubator/rtk-query';
273+
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query';
274274
export const api = createApi({
275275
baseQuery: fetchBaseQuery({ baseUrl: '/api/v3' }),
276276
tagTypes: [],
@@ -497,8 +497,8 @@ export type User = {
497497
`;
498498

499499
exports[`CLI options testing should generate react hooks as a part of the output 1`] = `
500-
import { createApi } from "@rtk-incubator/rtk-query/react";
501-
import { fetchBaseQuery } from "@rtk-incubator/rtk-query";
500+
import { createApi } from "@reduxjs/toolkit/query/react";
501+
import { fetchBaseQuery } from "@reduxjs/toolkit/query";
502502
export const api = createApi({
503503
baseQuery: fetchBaseQuery({ baseUrl: "/api/v3" }),
504504
tagTypes: [],
@@ -799,7 +799,7 @@ export const {
799799
`;
800800

801801
exports[`CLI options testing should log output to the console when a filename is not specified 1`] = `
802-
import { createApi, fetchBaseQuery } from "@rtk-incubator/rtk-query";
802+
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query";
803803
export const api = createApi({
804804
baseQuery: fetchBaseQuery({ baseUrl: "/api/v3" }),
805805
tagTypes: [],
@@ -1078,7 +1078,7 @@ export type User = {
10781078
`;
10791079

10801080
exports[`yaml parsing should be able to use read a yaml file and create a file with the output when --file is specified 1`] = `
1081-
import { createApi, fetchBaseQuery } from '@rtk-incubator/rtk-query';
1081+
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query';
10821082
export const api = createApi({
10831083
baseQuery: fetchBaseQuery({ baseUrl: '/api/v3' }),
10841084
tagTypes: [],
@@ -1298,7 +1298,7 @@ export type User = {
12981298
`;
12991299

13001300
exports[`yaml parsing should parse a yaml schema from a URL 1`] = `
1301-
import { createApi, fetchBaseQuery } from "@rtk-incubator/rtk-query";
1301+
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query";
13021302
export const api = createApi({
13031303
baseQuery: fetchBaseQuery({ baseUrl: "/api/v3" }),
13041304
tagTypes: [],

test/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('CLI options testing', () => {
9494
'.'
9595
);
9696

97-
expect(result.stdout).toContain(`import { createApi } from \"@rtk-incubator/rtk-query/react\";`);
97+
expect(result.stdout).toContain(`import { createApi } from \"@reduxjs/toolkit/query/react\";`);
9898
expect(result.stdout).toContain(`import { anotherNamedBaseQuery } from \"test/fixtures/customBaseQuery\";`);
9999
});
100100

test/fixtures/generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createApi, fetchBaseQuery } from '@rtk-incubator/rtk-query';
1+
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
22
export const api = createApi({
33
baseQuery: fetchBaseQuery({ baseUrl: '/api/v3' }),
44
tagTypes: [],

0 commit comments

Comments
 (0)