How to use the graphql-config.getGraphQLProjectConfig 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 coralproject / talk / src / core / common / graphql / loadSchema.ts View on Github external
export default function loadSchema(
  projectName: string,
  resolvers: IResolvers,
  resolverValidationOptions?: IResolverValidationOptions
) {
  // Load the configuration from the provided `.graphqlconfig` file.
  const config = getGraphQLProjectConfig(__dirname, projectName);

  // Get the GraphQLSchema from the configuration.
  const schema = config.getSchema();

  // Attach the resolvers to the schema.
  addResolveFunctionsToSchema({ schema, resolvers, resolverValidationOptions });

  return schema;
}
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'))
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')) {
github github / webpack-config-github / webpack.config.js View on Github external
function tryGetGraphQLProjectConfig() {
  try {
    return getGraphQLProjectConfig()
  } catch (error) {
    if (error.name === 'ConfigNotFoundError') {
      return {}
    } else {
      throw error
    }
  }
}
github dotansimha / graphql-code-generator / packages / graphql-codegen-cli / src / old-cli-config.ts View on Github external
export const validateCliOptions = (options: CLIOptions) => {
  const schema = options.schema;
  const template = options.template;
  const project = options.project;

  if (!schema && isNode) {
    const { getGraphQLProjectConfig, ConfigNotFoundError } = require('graphql-config');

    try {
      const graphqlProjectConfig = getGraphQLProjectConfig(project);
      options.schema = graphqlProjectConfig.schemaPath;
    } catch (e) {
      if (e instanceof ConfigNotFoundError) {
        cliError('Flag --schema is missing!');
      }
    }
  }

  if (!template && !project) {
    cliError('Please specify language/platform, using --template flag!');
  }
};