node_modules.apollo-codegen.src.utilities.printing.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-client-maven-plugin Show documentation
Show all versions of apollo-client-maven-plugin Show documentation
Maven plugin for generating graphql clients
// Code generation helper functions copied from graphql-js (https://github.com/graphql/graphql-js)
/**
* Given maybeArray, print an empty string if it is null or empty, otherwise
* print all items together separated by separator if provided
*/
export function join(maybeArray?: any[], separator?: string) {
return maybeArray ? maybeArray.filter(x => x).join(separator || '') : '';
}
/**
* Given array, print each item on its own line, wrapped in an
* indented "{ }" block.
*/
export function block(array: any[]) {
return array && array.length !== 0 ?
indent('{\n' + join(array, '\n')) + '\n}' :
'{}';
}
/**
* If maybeString is not null or empty, then wrap with start and end, otherwise
* print an empty string.
*/
export function wrap(start: string, maybeString?: string, end?: string) {
return maybeString ?
start + maybeString + (end || '') :
'';
}
export function indent(maybeString?: string) {
return maybeString && maybeString.replace(/\n/g, '\n ');
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy