How to use the graphql-tools/dist/transforms/visitSchema.VisitSchemaKind.INTERFACE_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 artsy / metaphysics / src / schema / v2 / FilterFields.ts View on Github external
return new GraphQLObjectType({
              fields,
              name: type.name,
              description: type.description,
              astNode: type.astNode,
              extensionASTNodes: type.extensionASTNodes,
              isTypeOf: type.isTypeOf,
              interfaces: type.getInterfaces(),
            })
          }
        } else {
          return undefined
        }
      }) as TypeVisitor,

      [VisitSchemaKind.INTERFACE_TYPE]: ((type: GraphQLInterfaceType) => {
        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 GraphQLInterfaceType({
              fields,
              name: type.name,
              description: type.description,
              astNode: type.astNode,
              resolveType: type.resolveType,
              extensionASTNodes: type.extensionASTNodes,
            })
          }
        } else {
github artsy / metaphysics / src / schema / v2 / transforms / FilterFields.ts View on Github external
return new GraphQLObjectType({
              fields,
              name: type.name,
              description: type.description,
              astNode: type.astNode,
              extensionASTNodes: type.extensionASTNodes,
              isTypeOf: type.isTypeOf,
              interfaces: type.getInterfaces(),
            })
          }
        } else {
          return undefined
        }
      }) as TypeVisitor,

      [VisitSchemaKind.INTERFACE_TYPE]: ((type: GraphQLInterfaceType) => {
        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 GraphQLInterfaceType({
              fields,
              name: type.name,
              description: type.description,
              astNode: type.astNode,
              resolveType: type.resolveType,
              extensionASTNodes: type.extensionASTNodes,
            })
          }
        } else {
github apollo-model / apollo-model / packages / schema-filter / src / index.js View on Github external
newSchema = visitSchema(newSchema, {
          [VisitSchemaKind.OBJECT_TYPE]: type => {
            if (Object.keys(type.getFields()).length === 0) {
              smthRemoved = true;
              return null;
            }
            return undefined;
          },
          [VisitSchemaKind.INPUT_OBJECT_TYPE]: type => {
            if (Object.keys(type.getFields()).length === 0) {
              smthRemoved = true;
              return null;
            }
            return undefined;
          },
          [VisitSchemaKind.INTERFACE_TYPE]: type => {
            if (Object.keys(type.getFields()).length === 0) {
              smthRemoved = true;
              return null;
            }
            return undefined;
          },
        });
      } while (smthRemoved);

      Object.values(schema.getTypeMap()).forEach(type => {
        if (type.name.startsWith('__')) return;
        if (type instanceof GraphQLInputObjectType) {
          Object.values(type.getFields()).forEach(field => {
            // if (
            //   !newSchema.getTypeMap()[type.name] ||
            //   !newSchema.getTypeMap()[type.name].getFields()[field.name]
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,
          fields: this.transformFields(type),
          resolveType: type.resolveType,
          extensionASTNodes: type.extensionASTNodes,
        })
      }) as TypeVisitor,
    })

    return newSchema
  }
github artsy / metaphysics / src / lib / stitching / exchange / transformers / replaceCommerceDateTimeType.ts View on Github external
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) => {
        const fields = this.transformFields(type)
        return (
          fields &&
          new GraphQLInterfaceType({
            fields,
            name: type.name,
            description: type.description,
            astNode: type.astNode,
            resolveType: type.resolveType,
            extensionASTNodes: type.extensionASTNodes,
          })
        )
      }) as TypeVisitor,
    })

    return newSchema
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,
          fields: this.transformFields(type),
          resolveType: type.resolveType,
          extensionASTNodes: type.extensionASTNodes,
        })
      }) as TypeVisitor,
    })

    return newSchema
  }
github artsy / metaphysics / src / schema / v2 / RenameFields.ts View on Github external
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) => {
        const fields = this.transformFields(type)
        return (
          fields &&
          new GraphQLInterfaceType({
            fields,
            name: type.name,
            description: type.description,
            astNode: type.astNode,
            resolveType: type.resolveType,
            extensionASTNodes: type.extensionASTNodes,
          })
        )
      }) as TypeVisitor,
    })

    this.newSchema = newSchema