How to use the graphql-config.resolveEnvsInValues function in graphql-config

To help you get started, we’ve selected a few graphql-config 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 prisma-labs / graphql-playground / packages / graphql-playground-electron / src / renderer / components / App.tsx View on Github external
if (input.cwd) {
      // use the endpoint as an alternative, only log the error
      try {
        configPath = findUp.sync(['.graphqlconfig', '.graphqlconfig.yml'], {
          cwd: input.cwd,
        })
        configString = configPath
          ? fs.readFileSync(configPath, 'utf-8')
          : undefined
        folderName = configPath
          ? path.basename(path.dirname(configPath))
          : undefined
        try {
          const rawConfig = getGraphQLConfig(input.cwd).config
          const resolvedConfig = resolveEnvsInValues(rawConfig, input.env)
          config = await patchEndpointsToConfigData(
            resolvedConfig,
            input.cwd,
            input.env,
          )
          config = await patchPrismaEndpointsToConfigData(
            resolvedConfig,
            input.cwd,
            input.env,
          )
        } catch (e) {
          const ymlPath = path.join(input.cwd, 'prisma.yml')
          if (!fs.existsSync(ymlPath)) {
            throw e
          }
          config = (await makeConfigFromPath(input.cwd, input.env)).config
github prisma-labs / graphql-playground / packages / graphql-playground-electron / src / renderer / components / App.tsx View on Github external
const configString = fs.readFileSync(configPath, 'utf-8')

      /* tslint:disable-next-line */
      //       if (configString.includes('${env:')) {
      //         errify(`You opened a .graphqlconfig file that includes environment variables.
      // In order to use environment variables in the Playground, please start it from the graphql cli. Install with
      // npm install -g graphql-cli
      // Then open the graphql config with:
      // cd ${folderPath}; graphql playground`)
      //       }

      const configDir = path.dirname(configPath)
      let config
      try {
        config = await patchEndpointsToConfigData(
          resolveEnvsInValues(getGraphQLConfig(configDir).config, env),
          configDir,
          env,
        )
        config = await patchPrismaEndpointsToConfigData(
          resolveEnvsInValues(getGraphQLConfig(configDir).config, env),
          configDir,
          env,
        )
      } catch (e) {
        const ymlPath = path.join(configDir, 'prisma.yml')
        if (!fs.existsSync(ymlPath)) {
          throw e
        }
        config = await makeConfigFromPath(configDir)
      }
github prisma-labs / graphql-playground / packages / graphql-playground-electron / src / renderer / components / App.tsx View on Github external
// In order to use environment variables in the Playground, please start it from the graphql cli. Install with
      // npm install -g graphql-cli
      // Then open the graphql config with:
      // cd ${folderPath}; graphql playground`)
      //       }

      const configDir = path.dirname(configPath)
      let config
      try {
        config = await patchEndpointsToConfigData(
          resolveEnvsInValues(getGraphQLConfig(configDir).config, env),
          configDir,
          env,
        )
        config = await patchPrismaEndpointsToConfigData(
          resolveEnvsInValues(getGraphQLConfig(configDir).config, env),
          configDir,
          env,
        )
      } catch (e) {
        const ymlPath = path.join(configDir, 'prisma.yml')
        if (!fs.existsSync(ymlPath)) {
          throw e
        }
        config = await makeConfigFromPath(configDir)
      }

      ipcRenderer.send(
        'cwd',
        JSON.stringify({ cwd: configDir, id: remote.getCurrentWindow().id }),
      )
      const state = {
github Urigo / graphql-cli / src / index.ts View on Github external
async getProjectConfig() {
        let config: GraphQLProjectConfig | undefined
        while (!config) {
          try {
            config = argv['project']
              ? getGraphQLProjectConfig(process.cwd(), argv['project'])
              : (getGraphQLProjectConfig(process.cwd()) as GraphQLProjectConfig)

            config.config = resolveEnvsInValues(config.config, process.env)
            config = await patchGraphcoolEndpointsToConfig(
              config,
              process.cwd(),
            )
            config = await patchPrismaEndpointsToConfig(config, process.cwd())
            config = await patchOpenApiEndpointsToConfig(config)
          } catch (error) {
            const config: GraphQLConfig = getGraphQLConfig(process.cwd())
            const projectNames = Object.keys(config.getProjects() || {})
            if (projectNames) {
              if (error.message.includes('multiproject')) {
                console.log(chalk.yellow('No project name specified'))
              } else if (error.message.includes('not a valid project name')) {
                console.log(chalk.yellow('Invalid project name specified'))
              }
              const { projectName } = await inquirer.prompt<{
github Urigo / graphql-cli / src / index.ts View on Github external
async getConfig() {
        let config = getGraphQLConfig(process.cwd())
        config.config = resolveEnvsInValues(config.config, process.env)
        config = await patchGraphcoolEndpointsToConfig(config)
        config = await patchPrismaEndpointsToConfig(config)
        config = await patchOpenApiEndpointsToConfig(config)
        return config
      },
    }