How to use the graphql-config.findGraphQLConfigFile 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
handleSelectFolder = async (folderPath: string) => {
    try {
      // Get config from folderPath
      const envPath = path.join(folderPath, '.env')
      let env = process.env
      if (fs.existsSync(envPath)) {
        const envString = fs.readFileSync(envPath)
        const localEnv = dotenv.parse(envString)
        if (localEnv) {
          env = merge(env, localEnv)
        }
      }
      const configPath = findGraphQLConfigFile(folderPath)
      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),
github graphql / graphiql / packages / graphql-language-service-server / src / MessageProcessor.js View on Github external
): Promise {
    if (!params) {
      throw new Error('`params` argument is required to initialize.');
    }

    const serverCapabilities: ServerCapabilities = {
      capabilities: {
        completionProvider: { resolveProvider: true },
        definitionProvider: true,
        textDocumentSync: 1,
        hoverProvider: true,
      },
    };

    const rootPath = dirname(
      findGraphQLConfigFile(configDir ? configDir.trim() : params.rootPath)
    );
    if (!rootPath) {
      throw new Error(
        '`--configDir` option or `rootPath` argument is required.'
      );
    }

    this._graphQLCache = await getGraphQLCache(rootPath);
    const config = getGraphQLConfig(rootPath);
    if (this._watchmanClient) {
      this._subcribeWatchman(config, this._watchmanClient);
    }
    this._languageService = new GraphQLLanguageService(this._graphQLCache);

    if (!serverCapabilities) {
      throw new Error('GraphQL Language Server is not initialized.');