@@ -6,12 +6,14 @@ import {
66} from '@graphql-codegen/visitor-plugin-common'
77import autoBind from 'auto-bind'
88import { GraphQLSchema , Kind , OperationDefinitionNode } from 'graphql'
9+ import glob from 'micromatch'
910import { pascalCase } from 'pascal-case'
1011
1112import { RawSWRPluginConfig } from './config'
1213
1314export interface SWRPluginConfig extends ClientSideBasePluginConfig {
1415 rawRequest : boolean
16+ exclude : string | string [ ]
1517}
1618
1719export class SWRVisitor extends ClientSideBaseVisitor <
@@ -31,7 +33,9 @@ export class SWRVisitor extends ClientSideBaseVisitor<
3133 fragments : LoadedFragment [ ] ,
3234 rawConfig : RawSWRPluginConfig
3335 ) {
34- super ( schema , fragments , rawConfig , { } )
36+ super ( schema , fragments , rawConfig , {
37+ exclude : rawConfig . exclude || null ,
38+ } )
3539
3640 autoBind ( this )
3741
@@ -67,7 +71,17 @@ export class SWRVisitor extends ClientSideBaseVisitor<
6771
6872 public get sdkContent ( ) : string {
6973 const allPossibleActions = this . _operationsToInclude
70- . filter ( ( o ) => o . operationType === 'Query' )
74+ . filter ( ( o ) => {
75+ if ( o . operationType !== 'Query' ) {
76+ return false
77+ }
78+ const { exclude } = this . config
79+ if ( ! exclude || ( Array . isArray ( exclude ) && ! exclude . length ) ) {
80+ return true
81+ }
82+ const name = o . node . name . value
83+ return ! glob . isMatch ( name , exclude )
84+ } )
7185 . map ( ( o ) => {
7286 const optionalVariables =
7387 ! o . node . variableDefinitions ||
0 commit comments