Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _buildClassComponent(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string): string {
const componentName: string = this.convertName(node.name.value + 'Component');
const apolloStencilComponentTag = paramCase(`Apollo${operationType}`);
const rendererSignature = toPascalCase(`${operationType}Renderer`);
return `
@Component({
tag: '${paramCase(`Apollo${toPascalCase(node.name.value)}`)}'
})
export class ${componentName} {
@Prop() renderer: import('stencil-apollo').${rendererSignature}<${operationResultType}, ${operationVariablesTypes}>;
@Prop() variables: ${operationVariablesTypes};
render() {
return <${apolloStencilComponentTag} ${operationType.toLowerCase()}={ ${documentVariableName} } variables={ this.variables } renderer={ this.renderer } />;
}
}
`;
}
private _buildClassComponent(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string): string {
const componentName: string = this.convertName(node.name.value + 'Component');
const apolloStencilComponentTag = paramCase(`Apollo${operationType}`);
const rendererSignature = toPascalCase(`${operationType}Renderer`);
return `
@Component({
tag: '${paramCase(`Apollo${toPascalCase(node.name.value)}`)}'
})
export class ${componentName} {
@Prop() renderer: import('stencil-apollo').${rendererSignature}<${operationResultType}, ${operationVariablesTypes}>;
@Prop() variables: ${operationVariablesTypes};
render() {
return <${apolloStencilComponentTag} ${operationType.toLowerCase()}={ ${documentVariableName} } variables={ this.variables } renderer={ this.renderer } />;
}
}
`;
}
const routes = ([pageName, ..._rest]) => {
return [
``,
]
}
deployTemplates(yeoman, injections) {
const component = this.getComponentManifest(yeoman);
if (component === null) {
return null;
}
const templatePath = yeoman.templatePath(component.templatePath);
const ejsInject = {
componentClassName: component.componentClassName,
componentClassNameKebabCase: paramCase(component.componentClassName),
componentNameCamelCase: component.componentClassName,
componentStrings: component.componentClassName + 'Strings',
componentPath: component.componentPath,
componentName: component.componentName
};
Object.assign(ejsInject, injections);
this.deployTemplatesToPath(yeoman, ejsInject, templatePath, component.componentPath);
}
return className => paramCase(className);
case "camel":
private _buildOperationFunctionalComponent(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string): string {
const operationName: string = this.convertName(node.name.value);
const propsTypeName: string = this.convertName(operationName + 'Props');
const rendererSignature = toPascalCase(`${operationType}Renderer`) + `<${operationResultType}, ${operationVariablesTypes}>`;
const apolloStencilComponentTag = paramCase(`Apollo${operationType}`);
const componentName = this.convertName(`${operationName}Component`);
const propsVar = `
export type ${propsTypeName} = {
variables ?: ${operationVariablesTypes};
inlist ?: StencilApollo.${rendererSignature};
};
`;
const component = `
export const ${componentName} = (props: ${propsTypeName}, children: [StencilApollo.${rendererSignature}]) => (
<${apolloStencilComponentTag} ${operationType.toLowerCase()}={ ${documentVariableName} } { ...props } renderer={ children[0] } />
);
`;
return [propsVar, component].filter(a => a).join('\n');