-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(graphql): make options.ts and options.spec.ts files swizzleable??
- Loading branch information
Showing
1 changed file
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,43 @@ module.exports = { | |
group: "Data Provider", | ||
swizzle: { | ||
items: [ | ||
{ | ||
group: "Providers", | ||
label: "GraphQL Default Options", | ||
requiredPackages: [ | ||
"@urql/[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
], | ||
files: [ | ||
{ | ||
src: "./src/dataProvider/options.ts", | ||
dest: "./providers/graphql/dataProvider/options.ts", | ||
}, | ||
{ | ||
src: "./test/utils/options.spec.ts", | ||
dest: "./providers/graphql/dataProvider/options.spec.ts", | ||
}, | ||
], | ||
message: ` | ||
**\`Usage\`** | ||
\`\`\` | ||
You can modify the swizzled options.ts file and pass it to the GraphQL data provider as a 2nd argument. | ||
import createDataProvider from "@refinedev/graphql"; | ||
const myOptions = { /* your options */ }; | ||
const dataProvider = createDataProvider(client, myOptions); | ||
\`\`\` | ||
`, | ||
}, | ||
{ | ||
group: "Providers", | ||
label: "GraphQL", | ||
requiredPackages: [ | ||
"@urql/[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
|
@@ -51,7 +84,7 @@ module.exports = { | |
\`\`\` | ||
// title: App.tsx | ||
import dataProvider, { liveProvider } from "providers/graphql"; | ||
import createDataProvider, { createLiveProvider } from "providers/graphql"; | ||
import { Client, fetchExchange } from "@urql/core"; | ||
import { createClient } from "graphql-ws"; | ||
|
@@ -60,13 +93,17 @@ module.exports = { | |
const client = new Client({ url: API_URL, exchanges: [fetchExchange] }); | ||
const dataProvider = createDataProvider(client) | ||
const wsClient = createClient({ url: WS_URL }) | ||
const liveProvider = createLiveProvider(wsClient) | ||
const App = () => { | ||
return ( | ||
<Refine | ||
dataProvider={dataProvider(client)} | ||
liveProvider={liveProvider(wsClient)} | ||
dataProvider={dataProvider} | ||
liveProvider={liveProvider} | ||
/* ... */ | ||
/> | ||
); | ||
|