-
Notifications
You must be signed in to change notification settings - Fork 463
Support disabling literal stripping when extracting operations. #1703
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
Changes from 4 commits
1ae7f11
f9aa0a0
d78cce8
fcc4724
af125d5
9d0c5f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||
| import { flags } from "@oclif/command"; | ||||||
| import { writeFileSync } from "fs"; | ||||||
| import { ClientCommand } from "../../Command"; | ||||||
| import { | ||||||
|
|
@@ -9,7 +10,13 @@ import { ClientIdentity } from "apollo-language-server"; | |||||
| export default class ClientExtract extends ClientCommand { | ||||||
| static description = "Extract queries from a client"; | ||||||
| static flags = { | ||||||
| ...ClientCommand.flags | ||||||
| ...ClientCommand.flags, | ||||||
| stripLiterals: flags.boolean({ | ||||||
| description: | ||||||
| "Whether to strip literals from extracted queries. DEFAULT: true", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| default: true, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If heeding my suggestion above, this default would become |
||||||
| allowNo: true | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we could get rid of this if the default was
Suggested change
|
||||||
| }) | ||||||
| }; | ||||||
|
|
||||||
| static args = [ | ||||||
|
|
@@ -30,7 +37,9 @@ export default class ClientExtract extends ClientCommand { | |||||
| { | ||||||
| title: "Extracting operations from project", | ||||||
| task: async ctx => { | ||||||
| ctx.operations = getOperationManifestFromProject(this.project); | ||||||
| ctx.operations = getOperationManifestFromProject(this.project, { | ||||||
| stripLiterals: flags.stripLiterals | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also suggest renaming this to more accurately describe its scope:
Suggested change
|
||||||
| }); | ||||||
| ctx.clientIdentity = config.client; | ||||||
| } | ||||||
| }, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,14 +13,16 @@ export interface ManifestEntry { | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export function getOperationManifestFromProject( | ||||||||||||||
| project: GraphQLClientProject | ||||||||||||||
| project: GraphQLClientProject, | ||||||||||||||
| options: { stripLiterals: boolean } = { stripLiterals: true } | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably, the default should also flip to false? :) |
||||||||||||||
| ): ManifestEntry[] { | ||||||||||||||
| const manifest = Object.entries( | ||||||||||||||
| project.mergedOperationsAndFragmentsForService | ||||||||||||||
| ).map(([operationName, operationAST]) => { | ||||||||||||||
| const printed = defaultOperationRegistrySignature( | ||||||||||||||
| operationAST, | ||||||||||||||
| operationName | ||||||||||||||
| operationName, | ||||||||||||||
| { stripLiterals: options.stripLiterals } | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| ); | ||||||||||||||
|
|
||||||||||||||
| return { | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since "literals" also applies to object and list literals (which are not stripped), perhaps we should be a bit more clear with this option name. Even if it's a bit wordy, the intent is more clear, I think? (And its less necessary for someone to understand the notion of negated flags and perhaps more intrinsic understanding of the default behavior?). This change would require changing the
defaulttofalsebelow and flipping other conditionals too, of course.)