Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting query name in cell generator #6442

Merged
merged 14 commits into from Sep 26, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 15 additions & 19 deletions packages/cli/src/commands/generate/cell/cell.js
Expand Up @@ -64,28 +64,24 @@ export const files = async ({
// override operationName so that its find_operationName
}

let operationName = options.query == null ? '' : options.query.trim()
if (operationName == '') {
let operationName = options.query
if (operationName) {
const userSpecifiedOperationNameIsUnique = await operationNameIsUnique(
operationName
)
if (!userSpecifiedOperationNameIsUnique) {
if (!options.force) {
dac09 marked this conversation as resolved.
Show resolved Hide resolved
throw new Error(
`Specified query name: "${operationName}" is not unique! If you still wish to continue please run command again with the --force flag.`
)
} else {
// TODO: Warn the user they forced a non-unique name?
}
}
} else {
operationName = await uniqueOperationName(cellName, {
list: shouldGenerateList,
})
} else {
const userSpecifiedNameIsUnique = await operationNameIsUnique(operationName)
if (!userSpecifiedNameIsUnique) {
const answer = await prompts([
{
type: 'confirm',
name: 'continue',
message: `Specified query name: "${operationName}" is not unique! Do you wish to continue?\r\n`,
initial: false,
active: 'Yes',
inactive: 'No',
},
])
if (!answer.continue) {
process.exit(0)
}
}
}

const cellFile = templateForComponentFile({
Expand Down