File tree Expand file tree Collapse file tree
packages/presets/near-operation-file/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -264,10 +264,14 @@ export const preset: Types.OutputPreset<NearOperationFileConfig> = {
264264 schemaObject ,
265265 {
266266 baseDir,
267- generateFilePath ( location : string ) {
267+ generateFilePath ( location , operationName ) {
268268 const newFilePath = defineFilepathSubfolder ( location , folder ) ;
269269
270- return appendFileNameToFilePath ( newFilePath , fileName , extension ) ;
270+ return appendFileNameToFilePath (
271+ newFilePath ,
272+ filePerOperation ? operationName : fileName ,
273+ extension ,
274+ ) ;
271275 } ,
272276 schemaTypesSource : {
273277 path : shouldAbsolute ? join ( options . baseOutputDir , baseTypesPath ) : baseTypesPath ,
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export type DocumentImportResolverOptions = {
2525 /**
2626 * Generates a target file path from the source `document.location`
2727 */
28- generateFilePath : ( location : string ) => string ;
28+ generateFilePath : ( location : string , operationName : string ) => string ;
2929 /**
3030 * Schema base types source
3131 */
@@ -69,7 +69,12 @@ export function resolveDocumentImports<T>(
6969
7070 return documents . map ( documentFile => {
7171 try {
72- const generatedFilePath = generateFilePath ( documentFile . location ) ;
72+ // FIXME
73+ const operationName =
74+ documentFile . document . definitions . find ( d => d . kind === 'OperationDefinition' ) ?. name
75+ ?. value ?? documentFile . document . definitions [ 0 ] . name . value ;
76+
77+ const generatedFilePath = generateFilePath ( documentFile . location , operationName ) ;
7378 const importStatements : string [ ] = [ ] ;
7479 const { externalFragments, fragmentImports } = resolveFragments (
7580 generatedFilePath ,
You can’t perform that action at this time.
0 commit comments