How to use the graphql-language-service-interface.GraphQLLanguageService function in graphql-language-service-interface

To help you get started, we’ve selected a few graphql-language-service-interface 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 graphql / graphiql / src / server / MessageProcessor.js View on Github external
): Promise {
  const serverCapabilities = {
    capabilities: {
      completionProvider: {resolveProvider: true},
      definitionProvider: true,
      textDocumentSync: 1,
    },
  };

  const configDir = findGraphQLConfigDir(rootPath);
  if (!configDir) {
    return null;
  }

  graphQLCache = await getGraphQLCache(configDir);
  languageService = new GraphQLLanguageService(graphQLCache);

  return serverCapabilities;
}
github graphql / graphiql / packages / graphql-language-service-server / src / MessageProcessor.js View on Github external
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.');
    }

    this._isInitialized = true;

    this._logger.log(
      JSON.stringify({
        type: 'usage',
        messageType: 'initialize',
      })
    );

    return serverCapabilities;
  }
github graphql / graphiql / src / server / MessageProcessor.js View on Github external
if (!graphQLConfigDir) {
      process.stdout.write(JSON.stringify(
        convertToRpcMessage({
          id: '-1',
          error: {
            code: ERROR_CODES.SERVER_NOT_INITIALIZED,
            message: '.graphqlrc not found',
          },
        }),
      ));
      return;
    }
    graphQLCache = await getGraphQLCache(graphQLConfigDir);
  }
  if (!languageService) {
    languageService = new GraphQLLanguageService(graphQLCache);
  }

  let json;

  try {
    json = JSON.parse(message);
  } catch (error) {
    process.stdout.write(JSON.stringify(
      convertToRpcMessage({
        id: '-1',
        error: {
          code: ERROR_CODES.PARSE_ERROR,
          message: 'Request contains incorrect JSON format',
        },
      }),
    ));