@@ -36,8 +36,8 @@ export const builder = {
36
36
}
37
37
} ;
38
38
39
- function getSchema ( config , basePath ) {
40
- const schemaPath = path . join ( basePath , config . schemaPath ) ;
39
+ function getSchema ( config ) {
40
+ const schemaPath = config . schemaPath ;
41
41
const schemaContents = fs . readFileSync ( schemaPath ) . toString ( ) ;
42
42
return buildASTSchema ( parse ( schemaContents ) ) ;
43
43
} ;
@@ -84,15 +84,15 @@ function getEndpoint(config, argv) {
84
84
if ( typeof ( endpoint ) === "string" ) {
85
85
endpoint = { url : endpoint } ;
86
86
}
87
- console . log ( chalk . green ( `Using endpoint ${ key } : ${ JSON . stringify ( endpoint ) } ` ) ) ;
87
+ console . log ( chalk . green ( `Using endpoint ${ key } : ${ JSON . stringify ( endpoint ) } ` ) ) ;
88
88
return endpoint ;
89
89
}
90
90
91
- function getMutation ( config , basePath , argv ) {
91
+ function getMutation ( config , argv ) {
92
92
const extensions = config . extensions || { } ;
93
93
const options = extensions . load || { } ;
94
94
95
- const schema = getSchema ( config , basePath ) ;
95
+ const schema = getSchema ( config ) ;
96
96
97
97
const mutationType = schema . getMutationType ( )
98
98
if ( ! mutationType ) {
@@ -169,22 +169,24 @@ function parseJson(str) {
169
169
}
170
170
}
171
171
172
- export const handler = async ( { getConfig} , argv ) => {
173
- const { config, configPath} = getConfig ( ) ;
174
- const basePath = path . dirname ( configPath ) ;
172
+ exports . handler = async function ( context , argv ) {
173
+ const config = await context . getProjectConfig ( )
174
+ const schema = config . getSchemaSDL ( ) ;
175
+ const configPath = config . configPath
176
+
175
177
const extensions = config . extensions || { } ;
176
178
const options = extensions . load || { } ;
177
179
178
180
const endpoint = getEndpoint ( config , argv ) ;
179
181
if ( ! endpoint ) return ;
180
182
181
- const mutationField = getMutation ( config , basePath , argv ) ;
183
+ const mutationField = getMutation ( config , argv ) ;
182
184
if ( ! mutationField ) return ;
183
185
184
186
var args = { } ;
185
187
mutationField . args . forEach ( ( arg ) => args [ arg . name ] = arg ) ;
186
188
187
- const data = readFile ( basePath , options , argv ) ;
189
+ const data = readFile ( path . dirname ( configPath ) , options , argv ) ;
188
190
const mapping = parseJson ( argv . mapping || "null" ) || options . mapping || { } ;
189
191
if ( Object . keys ( mapping ) . length > 0 ) {
190
192
console . log ( chalk . yellow ( `Using mapping: ${ JSON . stringify ( mapping ) } ` ) ) ;
0 commit comments