@@ -4,6 +4,7 @@ import { getExtNameFromFilePath } from './libs/extname';
44import createVisitor , { PluckedContent } from './visitor' ;
55import traverse from '@babel/traverse' ;
66import { freeText } from './utils' ;
7+ import { Source } from 'graphql' ;
78
89/**
910 * Additional options for determining how a file is parsed.
@@ -128,7 +129,7 @@ export const gqlPluckFromCodeString = async (
128129 filePath : string ,
129130 code : string ,
130131 options : GraphQLTagPluckOptions = { }
131- ) : Promise < string > => {
132+ ) : Promise < Source [ ] > => {
132133 validate ( { code, options } ) ;
133134
134135 const fileExt = extractExtension ( filePath ) ;
@@ -137,9 +138,7 @@ export const gqlPluckFromCodeString = async (
137138 code = await pluckVueFileScript ( code ) ;
138139 }
139140
140- return parseCode ( { code, filePath, options } )
141- . map ( t => t . content )
142- . join ( '\n\n' ) ;
141+ return parseCode ( { code, filePath, options } ) . map ( t => new Source ( t . content , filePath , t . loc . start ) ) ;
143142} ;
144143
145144/**
@@ -155,7 +154,7 @@ export const gqlPluckFromCodeStringSync = (
155154 filePath : string ,
156155 code : string ,
157156 options : GraphQLTagPluckOptions = { }
158- ) : string => {
157+ ) : Source [ ] => {
159158 validate ( { code, options } ) ;
160159
161160 const fileExt = extractExtension ( filePath ) ;
@@ -164,9 +163,7 @@ export const gqlPluckFromCodeStringSync = (
164163 code = pluckVueFileScriptSync ( code ) ;
165164 }
166165
167- return parseCode ( { code, filePath, options } )
168- . map ( t => t . content )
169- . join ( '\n\n' ) ;
166+ return parseCode ( { code, filePath, options } ) . map ( t => new Source ( t . content , filePath , t . loc . start ) ) ;
170167} ;
171168
172169export function parseCode ( {
0 commit comments