Skip to content

Commit 2adcdbe

Browse files
committed
Rename exclude option to excludeQueries
1 parent cd8fbe8 commit 2adcdbe

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ generates:
1717
config:
1818
rawRequest: false
1919
# exclude queries that are matched by micromatch (case-sensitive)
20-
exclude:
20+
excludeQueries:
2121
- foo*
2222
- bar
2323
```

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ export interface RawSWRPluginConfig extends RawClientSideBasePluginConfig {
2323
* ```
2424
*/
2525
rawRequest?: boolean
26-
exclude?: string | string[]
26+
excludeQueries?: string | string[]
2727
useSWRInfinite?: string | string[]
2828
}

src/visitor.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { RawSWRPluginConfig } from './config'
1313

1414
export interface SWRPluginConfig extends ClientSideBasePluginConfig {
1515
rawRequest: boolean
16-
exclude: string | string[]
16+
excludeQueries: string | string[]
1717
useSWRInfinite: string | string[]
1818
}
1919

@@ -37,7 +37,7 @@ export class SWRVisitor extends ClientSideBaseVisitor<
3737
rawConfig: RawSWRPluginConfig
3838
) {
3939
super(schema, fragments, rawConfig, {
40-
exclude: rawConfig.exclude || null,
40+
excludeQueries: rawConfig.excludeQueries || null,
4141
useSWRInfinite: rawConfig.useSWRInfinite || null,
4242
})
4343

@@ -93,19 +93,20 @@ export class SWRVisitor extends ClientSideBaseVisitor<
9393
}
9494

9595
public get sdkContent(): string {
96-
const { exclude } = this.config
97-
const disabledExclude =
98-
!exclude || (Array.isArray(exclude) && !exclude.length)
96+
const { excludeQueries } = this.config
97+
const disabledexcludeQueries =
98+
!excludeQueries ||
99+
(Array.isArray(excludeQueries) && !excludeQueries.length)
99100
const allPossibleActions = this._operationsToInclude
100101
.filter((o) => {
101102
if (o.operationType !== 'Query') {
102103
return false
103104
}
104-
if (disabledExclude) {
105+
if (disabledexcludeQueries) {
105106
return true
106107
}
107108
const name = o.node.name.value
108-
return !glob.isMatch(name, exclude)
109+
return !glob.isMatch(name, excludeQueries)
109110
})
110111
.map((o) => {
111112
const optionalVariables =

tests/swr.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;`
240240
)
241241
})
242242

243-
it('Should work `exclude` option correctly', async () => {
243+
it('Should work `excludeQueries` option correctly', async () => {
244244
const config: PluginsConfig = {
245-
exclude: ['feed[2-3]', 'hoge', 'foo'],
245+
excludeQueries: ['feed[2-3]', 'hoge', 'foo'],
246246
}
247247
const docs = [{ location: '', document: basicDoc }]
248248

0 commit comments

Comments
 (0)