How to use prisma-yml - 4 common examples

To help you get started, we’ve selected a few prisma-yml 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-config-extension-prisma / src / index.ts View on Github external
config: GraphQLConfigData,
  cwd?: string,
  envVars?: { [key: string]: any },
  graceful?: boolean,
): Promise {
  // return early if no prisma extension found
  const allExtensions = [config.extensions, ...values(config.projects).map(p => p.extensions)]
  if (!allExtensions.some(e => e && e.prisma)) {
    return config
  }

  const newConfig = { ...config }

  const home = os.homedir()

  const env = new Environment(home)
  await env.load()

  if (newConfig.extensions && newConfig.extensions.prisma) {
    set(
      newConfig,
      ['extensions', 'endpoints'],
      await getEndpointsFromPath(env, newConfig.extensions.prisma, cwd, envVars, graceful),
    )
  }

  if (newConfig.projects) {
    await Promise.all(
      Object.keys(newConfig.projects).map(async projectName => {
        const project = newConfig.projects![projectName]
        if (project.extensions && project.extensions.prisma) {
          set(
github prisma-labs / graphql-config-extension-prisma / src / index.ts View on Github external
export async function makeConfigFromPath(
  cwd: string = process.cwd(),
  envVars?: { [key: string]: any },
): Promise {
  const ymlPath = path.join(cwd, 'prisma.yml')
  if (!fs.existsSync(ymlPath)) {
    return null
  }

  const home = os.homedir()
  const env = new Environment(home)
  await env.load()

  const definition = new PrismaDefinitionClass(env, ymlPath, envVars)
  await definition.load({})
  const serviceName = definition.service!
  const stage = definition.stage!
  const clusterName = definition.cluster
  if (!clusterName) {
    throw new Error(`No cluster set. Please set the "cluster" property in your prisma.yml`)
  }
  const cluster = await definition.getCluster()
  if (!cluster) {
    throw new Error(
      `Cluster ${clusterName} provided in prisma.yml could not be found in global ~/.prisma/config.yml.
Please check in ~/.prisma/config.yml, if the cluster exists.
You can use \`docker-compose up -d\` to start a new cluster.`,
    )
  }
  const url = cluster.getApiEndpoint(serviceName, stage, definition.getWorkspace() || undefined)
github prisma-labs / graphql-config-extension-prisma / src / index.ts View on Github external
async function getEndpointsFromPath(
  env: Environment,
  ymlPath: string,
  cwd?: string,
  envVars?: { [key: string]: any },
  graceful?: boolean,
): Promise {
  const joinedYmlPath = cwd ? path.join(cwd, ymlPath) : ymlPath
  const definition = new PrismaDefinitionClass(env, joinedYmlPath, envVars)
  await definition.load({}, undefined, graceful)
  const serviceName = definition.service!
  const stage = definition.stage!
  const clusterName = definition.cluster
  if (!clusterName) {
    throw new Error(`No cluster set. Please set the "cluster" property in your prisma.yml`)
  }
  const cluster = await definition.getCluster()
  if (!cluster) {
    throw new Error(
      `Cluster ${clusterName} provided in prisma.yml could not be found in global ~/.prisma/config.yml.
Please check in ~/.prisma/config.yml, if the cluster exists.
You can use \`docker-compose up -d\` to start a new cluster.`,
    )
  }
  const url = cluster.getApiEndpoint(serviceName, stage, definition.getWorkspace() || undefined)
github prisma-labs / graphql-config-extension-prisma / src / index.ts View on Github external
export async function makeConfigFromPath(
  cwd: string = process.cwd(),
  envVars?: { [key: string]: any },
): Promise {
  const ymlPath = path.join(cwd, 'prisma.yml')
  if (!fs.existsSync(ymlPath)) {
    return null
  }

  const home = os.homedir()
  const env = new Environment(home)
  await env.load()

  const definition = new PrismaDefinitionClass(env, ymlPath, envVars)
  await definition.load({})
  const serviceName = definition.service!
  const stage = definition.stage!
  const clusterName = definition.cluster
  if (!clusterName) {
    throw new Error(`No cluster set. Please set the "cluster" property in your prisma.yml`)
  }
  const cluster = await definition.getCluster()
  if (!cluster) {
    throw new Error(
      `Cluster ${clusterName} provided in prisma.yml could not be found in global ~/.prisma/config.yml.
Please check in ~/.prisma/config.yml, if the cluster exists.
You can use \`docker-compose up -d\` to start a new cluster.`,

prisma-yml

<a href="https://www.prismagraphql.com"><img src="https://imgur.com/HUu10rH.png" width="248" /></a>

Apache-2.0
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages