fix some fields getting created at wrong position
This commit is contained in:
parent
258e55774d
commit
1de69fc13b
|
@ -109,12 +109,12 @@ const replaceLast = (str: string, pattern: string | RegExp, replacement: string)
|
|||
}
|
||||
|
||||
export const operationParser: OperationParser = (root: string) => {
|
||||
let operation = `${root} {\n\t%${root}\n}`
|
||||
let operation = `${root} {\n\t|${root}|\n}`
|
||||
const fields: string[] = [root]
|
||||
|
||||
return {
|
||||
get() {
|
||||
return operation.replace(/(\n|,)?(\t+| )%\w+\b/g, "")
|
||||
return operation.replace(/(\n|,)?(\t+| )\|\w+\b\|/g, "")
|
||||
},
|
||||
set({ level, subField, alias, hasSubField, isUnion, variables = "" }) {
|
||||
fields.splice(level, 0, subField)
|
||||
|
@ -131,12 +131,15 @@ export const operationParser: OperationParser = (root: string) => {
|
|||
|
||||
const union = isUnion ? "... on " : ""
|
||||
alias = alias ? `${alias}: ` : ""
|
||||
subField = hasSubField ? `${` {\n${t(level + 1)}%${fields.at(-1)}\n${t(level)}}`}` : ""
|
||||
subField = hasSubField ? `${` {\n${t(level + 1)}|${fields.at(-1)}|\n${t(level)}}`}` : ""
|
||||
|
||||
operation = replaceLast(
|
||||
operation,
|
||||
`%${fields[level - 1]}`,
|
||||
`${union}${alias}${fields[level]}${variables}${subField}\n${t(level)}%${fields[level - 1]}`,
|
||||
`|${fields[level - 1]}|`,
|
||||
// RegExp("%" + fields[level - 1] + "(?<!\n)", ""),
|
||||
`${union}${alias}${fields[level]}${variables}${subField}\n${t(level)}|${
|
||||
fields[level - 1]
|
||||
}|`,
|
||||
)
|
||||
|
||||
return this
|
||||
|
|
Loading…
Reference in New Issue