How to use the @graphql-inspector/core.ChangeType.FieldAdded function in @graphql-inspector/core

To help you get started, we’ve selected a few @graphql-inspector/core 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 aerogear / graphback / packages / graphql-migrations / src / production / database / migrations / DataResourcesManager.ts View on Github external
logger.info(`Updating database schema`)

      for (const change of changes) {

        const parts = change.path.split('.');

        const changedType = {
          name: parts[0],
          field: parts[1],
        }

        const gqlType = types.find((t: InputModelTypeContext) => t.name === changedType.name);

        const tableName = context.getFieldName(gqlType);

        if (change.type === ChangeType.FieldAdded) {
          await this.addField(tableName, changedType.field, gqlType);
        }
        if (change.type === ChangeType.TypeAdded) {
          await this.addTable(tableName, gqlType);
        }
      }
    }
  }