How to use the graphql-tools/dist/transforms/visitSchema.VisitSchemaKind.OBJECT_TYPE function in graphql-tools

To help you get started, we’ve selected a few graphql-tools 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 strvcom / dep-manager-web / src / api / schema / lib / transform.ts View on Github external
public transformSchema(schema: GraphQLSchema) {
    const builder = getBuilder(schema)

    return visit(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: (type: GraphQLObjectType): GraphQLObjectType => {
        if (type.name.match(this.typeName)) {
          const config = type.toConfig()
          // parseType

          for (let fieldName in config.fields) {
            if (fieldName.match(this.name)) {
              config.fields[fieldName] = this.fieldTransform(config.fields[fieldName], {
                type,
                builder,
              })
            }
          }

          return new GraphQLObjectType(config)
        }
github artsy / metaphysics / src / schema / v2 / FilterFields.ts View on Github external
public transformSchema(schema: GraphQLSchema): GraphQLSchema {
    const newSchema = visitSchema(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: ((type: GraphQLObjectType) => {
        const fields = this.transformFields(type)
        if (fields) {
          // Leave type out if it's entirely empty after filtering fields.
          if (Object.keys(fields).length === 0) {
            return null
          } else {
            return new GraphQLObjectType({
              fields,
              name: type.name,
              description: type.description,
              astNode: type.astNode,
              extensionASTNodes: type.extensionASTNodes,
              isTypeOf: type.isTypeOf,
              interfaces: type.getInterfaces(),
            })
          }
github artsy / metaphysics / src / schema / v2 / transforms / FilterFields.ts View on Github external
public transformSchema(schema: GraphQLSchema): GraphQLSchema {
    const newSchema = visitSchema(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: ((type: GraphQLObjectType) => {
        const fields = this.transformFields(type)
        if (fields) {
          // Leave type out if it's entirely empty after filtering fields.
          if (Object.keys(fields).length === 0) {
            return null
          } else {
            return new GraphQLObjectType({
              fields,
              name: type.name,
              description: type.description,
              astNode: type.astNode,
              extensionASTNodes: type.extensionASTNodes,
              isTypeOf: type.isTypeOf,
              interfaces: type.getInterfaces(),
            })
          }
github apollo-model / apollo-model / packages / schema-filter / src / index.js View on Github external
return new GraphQLInterfaceType({
            name: type.name,
            // description: type.description,
            astNode: type.astNode,
            // isTypeOf: type.isTypeOf,
            fields: () =>
              fieldMapToFieldConfigMap(groupedFields[true], resolveType),
          });

          return undefined;
        },
      });

      //remove null from interfaces after first transformation
      newSchema = visitSchema(newSchema, {
        [VisitSchemaKind.OBJECT_TYPE]: type => {
          const interfaces = type.getInterfaces();
          let filteredInterfaces = interfaces.filter(iface => iface);

          if (filteredInterfaces.length === interfaces.length) {
            return undefined;
          }

          const fields = type.getFields();

          return new GraphQLObjectType({
            name: type.name,
            description: type.description,
            astNode: type.astNode,
            isTypeOf: type.isTypeOf,
            fields: () => fieldMapToFieldConfigMap(fields, resolveType, true),
            interfaces: () => filteredInterfaces,
github artsy / metaphysics / src / schema / v2 / RenameFields.ts View on Github external
public transformSchema(schema: GraphQLSchema): GraphQLSchema {
    const newSchema = visitSchema(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: ((type: GraphQLObjectType) => {
        const fields = this.transformFields(type)
        return (
          fields &&
          new GraphQLObjectType({
            fields,
            name: type.name,
            description: type.description,
            astNode: type.astNode,
            extensionASTNodes: type.extensionASTNodes,
            isTypeOf: type.isTypeOf,
            interfaces: type.getInterfaces(),
          })
        )
      }) as TypeVisitor,

      [VisitSchemaKind.INTERFACE_TYPE]: ((type: GraphQLInterfaceType) => {
github artsy / metaphysics / src / schema / v2 / transforms / RenameArguments.ts View on Github external
public transformSchema(schema: GraphQLSchema): GraphQLSchema {
    const newSchema = visitSchema(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: ((type: GraphQLObjectType) => {
        return new GraphQLObjectType({
          name: type.name,
          description: type.description,
          astNode: type.astNode,
          fields: this.transformFields(type),
          extensionASTNodes: type.extensionASTNodes,
          isTypeOf: type.isTypeOf,
          interfaces: type.getInterfaces(),
        })
      }) as TypeVisitor,

      [VisitSchemaKind.INTERFACE_TYPE]: ((type: GraphQLInterfaceType) => {
        return new GraphQLInterfaceType({
          name: type.name,
          description: type.description,
          astNode: type.astNode,
github artsy / metaphysics / src / lib / stitching / exchange / transformers / replaceCommerceDateTimeType.ts View on Github external
public transformSchema(schema: GraphQLSchema): GraphQLSchema {
    const newSchema = visitSchema(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: ((type: GraphQLObjectType) => {
        const fields = this.transformFields(type)
        return (
          fields &&
          new GraphQLObjectType({
            fields,
            name: type.name,
            description: type.description,
            astNode: type.astNode,
            extensionASTNodes: type.extensionASTNodes,
            isTypeOf: type.isTypeOf,
            interfaces: type.getInterfaces(),
          })
        )
      }) as TypeVisitor,

      [VisitSchemaKind.INTERFACE_TYPE]: ((type: GraphQLInterfaceType) => {
github artsy / metaphysics / src / schema / v2 / RemoveDeprecatedFields.ts View on Github external
public transformSchema(schema: GraphQLSchema): GraphQLSchema {
    const newSchema = visitSchema(schema, {
      [VisitSchemaKind.OBJECT_TYPE]: ((type: GraphQLObjectType) => {
        return new GraphQLObjectType({
          name: type.name,
          description: type.description,
          astNode: type.astNode,
          fields: this.transformFields(type),
          extensionASTNodes: type.extensionASTNodes,
          isTypeOf: type.isTypeOf,
          interfaces: type.getInterfaces(),
        })
      }) as TypeVisitor,

      [VisitSchemaKind.INTERFACE_TYPE]: ((type: GraphQLInterfaceType) => {
        return new GraphQLInterfaceType({
          name: type.name,
          description: type.description,
          astNode: type.astNode,