How to use the @graphql-codegen/visitor-plugin-common.toPascalCase function in @graphql-codegen/visitor-plugin-common

To help you get started, we’ve selected a few @graphql-codegen/visitor-plugin-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dotansimha / graphql-code-generator / packages / plugins / typescript / compatibility / src / visitor.ts View on Github external
export: 'const',
          name: `with${convertedName}`,
        };
      }

      if (component) {
        selectionSetTypes[prefix + 'Component'] = {
          export: 'const',
          name: this.convertName(baseName, { suffix: 'Component' }),
        };
      }

      if (hooks) {
        selectionSetTypes['use' + prefix] = {
          export: 'const',
          name: 'use' + this.convertName(baseName, { suffix: toPascalCase(node.operation) }),
        };
      }
    }

    const operationsBlock = this.printTypes(selectionSetTypes);

    if (!this.config.noNamespaces) {
      results.push(
        new DeclarationBlock(this._declarationBlockConfig)
          .export()
          .asKind('namespace')
          .withName(convertedName)
          .withBlock(operationsBlock).string
      );
    } else {
      results.push(operationsBlock);
github dotansimha / graphql-code-generator / packages / plugins / typescript / compatibility / src / visitor.ts View on Github external
protected buildOperationBlock(node: OperationDefinitionNode): SelectionSetToObjectResult {
    const typeName = this.getRootType(node.operation);
    const baseName = this.convertName(node.name.value, { suffix: `${toPascalCase(node.operation)}` });
    const typesPrefix = this.config.noNamespaces ? this.convertName(node.name.value) : '';
    const selectionSetTypes: SelectionSetToObjectResult = {
      [typesPrefix + this.convertName('Variables')]: {
        export: 'type',
        name: this.convertName(node.name.value, { suffix: `${toPascalCase(node.operation)}Variables` }),
      },
    };

    selectionSetToTypes(typesPrefix, this, this._schema, typeName, baseName, node.operation, node.selectionSet, this.config.preResolveTypes, selectionSetTypes);

    return selectionSetTypes;
  }
github ahrnee / graphql-codegen-hasura / packages / shared / utils.ts View on Github external
export function makePascalCase(typename: string) {
  return toPascalCase(typename);
}
github ahrnee / graphql-codegen-hasura / packages / shared / utils.ts View on Github external
export function makeShortName(typename: string, trimString: string = undefined) {
  return `${toPascalCase(trimString ? typename.replace(trimString, "") : typename)}`;
}
github dotansimha / graphql-code-generator / packages / plugins / java / apollo-android / src / operation-visitor.ts View on Github external
OperationDefinition(node: OperationDefinitionNode): string {
    this.visitingFragment = false;
    const operationType = toPascalCase(node.operation);
    const operationSchemaType = this.getRootType(node.operation);
    const className = node.name.value.endsWith(operationType) ? operationType : `${node.name.value}${operationType}`;
    this._imports.add(Imports[operationType]);
    this._imports.add(Imports.String);
    this._imports.add(Imports.Override);
    this._imports.add(Imports.Generated);
    this._imports.add(Imports.OperationName);
    this._imports.add(Imports.Operation);
    this._imports.add(Imports.ResponseFieldMapper);

    const cls = new JavaDeclarationBlock()
      .annotate([`Generated("Apollo GraphQL")`])
      .access('public')
      .final()
      .asKind('class')
      .withName(className);
github ahrnee / graphql-codegen-hasura / packages / shared / utils.ts View on Github external
export function getIdTypeScriptFieldType(field: FieldDefinitionNode): { typeName: string; isNative: boolean } {
  const postGresIdFieldType = getIdPostGresFieldType(field);
  if (postGresIdFieldType.endsWith("_enum")) {
    return { typeName: toPascalCase(postGresIdFieldType), isNative: false };
  } else if (postGresIdFieldType.toLowerCase() === "int") {
    return { typeName: "number", isNative: true };
  } else {
    return { typeName: "string", isNative: true };
  }
}
github dotansimha / graphql-code-generator / packages / plugins / typescript / compatibility / src / visitor.ts View on Github external
protected buildOperationBlock(node: OperationDefinitionNode): SelectionSetToObjectResult {
    const typeName = this.getRootType(node.operation);
    const baseName = this.convertName(node.name.value, { suffix: `${toPascalCase(node.operation)}` });
    const typesPrefix = this.config.noNamespaces ? this.convertName(node.name.value) : '';
    const selectionSetTypes: SelectionSetToObjectResult = {
      [typesPrefix + this.convertName('Variables')]: {
        export: 'type',
        name: this.convertName(node.name.value, { suffix: `${toPascalCase(node.operation)}Variables` }),
      },
    };

    selectionSetToTypes(typesPrefix, this, this._schema, typeName, baseName, node.operation, node.selectionSet, this.config.preResolveTypes, selectionSetTypes);

    return selectionSetTypes;
  }