@@ -49,76 +49,6 @@ function find(text: string): $ReadOnlyArray<GraphQLTag> {
49
49
const ast = babylon.parse(text, BABYLON_OPTIONS);
50
50
51
51
const visitors = {
52
- CallExpression : node => {
53
- const callee = node . callee ;
54
- if (
55
- ! (
56
- ( callee . type === 'Identifier' &&
57
- CREATE_CONTAINER_FUNCTIONS [ callee . name ] ) ||
58
- ( callee . kind === 'MemberExpression' &&
59
- callee . object . type === 'Identifier' &&
60
- callee . object . value === 'Relay' &&
61
- callee . property . type === 'Identifier' &&
62
- CREATE_CONTAINER_FUNCTIONS [ callee . property . name ] )
63
- )
64
- ) {
65
- traverse ( node , visitors ) ;
66
- return ;
67
- }
68
- const fragments = node . arguments [ 1 ] ;
69
- if ( fragments . type === 'ObjectExpression' ) {
70
- fragments . properties . forEach ( property => {
71
- invariant (
72
- property . type === 'ObjectProperty' &&
73
- property . key . type === 'Identifier' &&
74
- property . value . type === 'TaggedTemplateExpression' ,
75
- 'FindGraphQLTags: `%s` expects fragment definitions to be ' +
76
- '`key: graphql`.' ,
77
- node . callee . name ,
78
- ) ;
79
- invariant (
80
- isGraphQLModernOrDeprecatedTag ( property . value . tag ) ,
81
- 'FindGraphQLTags: `%s` expects fragment definitions to be tagged ' +
82
- 'with `graphql`, got `%s`.' ,
83
- node . callee . name ,
84
- getSourceTextForLocation ( text , property . value . tag . loc ) ,
85
- ) ;
86
- if ( isGraphQLTag ( property . value . tag ) ) {
87
- result . push ( {
88
- keyName : property . key . name ,
89
- template : getGraphQLText ( property . value . quasi ) ,
90
- sourceLocationOffset : getSourceLocationOffset (
91
- property . value . quasi ,
92
- ) ,
93
- } ) ;
94
- }
95
- } ) ;
96
- } else {
97
- invariant (
98
- fragments && fragments . type === 'TaggedTemplateExpression' ,
99
- 'FindGraphQLTags: `%s` expects a second argument of fragment ' +
100
- 'definitions.' ,
101
- node . callee . name ,
102
- ) ;
103
- invariant (
104
- isGraphQLModernOrDeprecatedTag ( fragments . tag ) ,
105
- 'FindGraphQLTags: `%s` expects fragment definitions to be tagged ' +
106
- 'with `graphql`, got `%s`.' ,
107
- node . callee . name ,
108
- getSourceTextForLocation ( text , fragments . tag . loc ) ,
109
- ) ;
110
- result . push ( {
111
- keyName : null ,
112
- template : getGraphQLText ( fragments . quasi ) ,
113
- sourceLocationOffset : getSourceLocationOffset ( fragments . quasi ) ,
114
- } ) ;
115
- }
116
-
117
- // Visit remaining arguments
118
- for ( let ii = 2 ; ii < node . arguments . length ; ii ++ ) {
119
- visit ( node . arguments [ ii ] , visitors ) ;
120
- }
121
- } ,
122
52
TaggedTemplateExpression : node => {
123
53
if ( isGraphQLTag ( node . tag ) ) {
124
54
result . push ( {
@@ -133,12 +63,6 @@ function find(text: string): $ReadOnlyArray<GraphQLTag> {
133
63
return result;
134
64
}
135
65
136
- const CREATE_CONTAINER_FUNCTIONS = Object . create ( null , {
137
- createFragmentContainer : { value : true } ,
138
- createPaginationContainer : { value : true } ,
139
- createRefetchContainer : { value : true } ,
140
- } );
141
-
142
66
const IGNORED_KEYS = {
143
67
comments : true ,
144
68
end : true ,
@@ -154,13 +78,6 @@ function isGraphQLTag(tag): boolean {
154
78
return tag . type === 'Identifier' && tag . name === 'graphql' ;
155
79
}
156
80
157
- function isGraphQLModernOrDeprecatedTag(tag): boolean {
158
- return (
159
- tag . type === 'Identifier' &&
160
- ( tag . name === 'graphql' || tag . name === 'graphql_DEPRECATED' )
161
- ) ;
162
- }
163
-
164
81
function getTemplateNode(quasi) {
165
82
const quasis = quasi . quasis ;
166
83
invariant (
@@ -170,10 +87,6 @@ function getTemplateNode(quasi) {
170
87
return quasis [ 0 ] ;
171
88
}
172
89
173
- function getGraphQLText(quasi): string {
174
- return getTemplateNode ( quasi ) . value . raw ;
175
- }
176
-
177
90
function getSourceLocationOffset(quasi) {
178
91
const loc = getTemplateNode ( quasi ) . loc . start ;
179
92
return {
@@ -182,16 +95,6 @@ function getSourceLocationOffset(quasi) {
182
95
} ;
183
96
}
184
97
185
- function getSourceTextForLocation(text, loc) {
186
- if ( loc == null ) {
187
- return '(source unavailable)' ;
188
- }
189
- const lines = text.split('\n').slice(loc.start.line - 1, loc.end.line);
190
- lines[0] = lines[0].slice(loc.start.column);
191
- lines[lines.length - 1] = lines[lines.length - 1].slice(0, loc.end.column);
192
- return lines.join('\n');
193
- }
194
-
195
98
function invariant(condition, msg, ...args) {
196
99
if ( ! condition ) {
197
100
throw new Error ( util . format ( msg , ...args ) ) ;
0 commit comments