npm package: @occupop/lib-graphql
Description: library used by microservices
Author: occupop
Latest version: 3.0.1

Claro! Aqui está o `README.md` traduzido para o inglês:

```markdown
# GraphQL Server Library

A library to set up a GraphQL server with Apollo Server, Express, and various useful configurations.

## Installation

```bash
npm install @kaueoccupop/lib-graphql
```

## Usage

### Basic Configuration

Create and configure a GraphQL server with type definitions, resolvers, and context.

```typescript
import express from 'express';
import { makeGraphqlServer, GraphqlServerInputParams } from '@kaueoccupop/lib-graphql';
import { typeDefs, resolvers } from './schema';
import { contextFunction } from './context';

const app = express();

const params: GraphqlServerInputParams = {
  port: 4000,
  sensitiveRoutesConfig: {
    '/auth/login': ['password'],
    '/auth/register': ['password', 'ssn'],
  },
  routeConfig: {
    router: express.Router(),
    prefix: '/api',
  },
  routes: [
    {
      method: 'post',
      path: '/custom-endpoint',
      handlers: [
        (req, res) => {
          res.send('Hello from custom endpoint!');
        },
      ],
    },
  ],
};

makeGraphqlServer({
  contextFunction,
  app,
  typeDefs,
  resolvers,
})(params).then(() => {
  console.log('Server is running...');
});
```

### Folder Structure

- `src/`
    - `index.ts` (main file)
    - `schema.ts` (type definitions and resolvers)
    - `context.ts` (context function)
    - `middleware/`
        - `logRouteMiddleware.ts` (middleware for route logging)

## Configurations

### GraphqlServerInputParams

| Property               | Type                          | Description                                                                                     |
|------------------------|-------------------------------|-------------------------------------------------------------------------------------------------|
| `port`                 | `number`                      | Port where the server will run                                                                  |
| `routeConfig`          | `RoutingConfig`               | Express router configuration                                                                    |
| `middlewares`          | `ApplicationRequestHandler[]` | List of express middlewares                                                                     |
| `routes`               | `HttpRoute[]`                 | Custom route definitions                                                                        |
| `errorRequestHandler`  | `ErrorRequestHandler`         | Custom error handler                                                                            |
| `sensitiveRoutesConfig`| `SensitiveRouteConfig`        | Configuration for routes and sensitive fields to be masked in logs                              |

### SensitiveRouteConfig

An object mapping routes to a list of sensitive fields that should be masked in the logs.

```typescript
const sensitiveRoutesConfig: SensitiveRouteConfig = {
  '/auth/login': ['password'],
  '/auth/register': ['password', 'ssn'],
};
```

### Publishing to npm

To publish the library to npm, follow these steps:

1. **Configure `package.json`**

Ensure your `package.json` is correctly configured with the name, version, and other necessary information.

```json
{
  "name": "@kaueoccupop/lib-graphql",
  "version": "1.0.0",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "scripts": {
    "build": "tsc",
    "prepublishOnly": "npm run build",
    "test": "jest",
    "cover": "jest --coverage"
  },
  "files": [
    "dist"
  ],
  "devDependencies": {
    "typescript": "^5.3.3",
    "ts-jest": "^29.1.2",
    "jest": "^29.7.0",
    "@types/jest": "^29.5.12"
  },
  "dependencies": {
    "@apollo/server": "^4.10.1",
    "@apollo/subgraph": "^2.7.1",
    "express": "^4.18.3",
    "cors": "^2.8.5",
    "helmet": "^7.1.0",
    "graphql": "^16.8.1",
    "body-parser": "^1.20.2",
    "dotenv": "^16.4.5",
    "express-rate-limit": "^7.2.0",
    "awilix": "^10.0.2"
  }
}
```

2. **Compile the Code**

Compile your TypeScript code to JavaScript.

```bash
npm run build
```

3. **Publish to npm**

Log in to your npm account and publish the library.

```bash
npm login
npm run publish:npm
```

## Notes

- **Helmet**: Used to set security-related HTTP headers.
- **Rate Limit**: Limits the number of requests per time window.
- **CORS**: Enables CORS for all routes.
- **Health Check**: Health check endpoint configured at `/health`.
- **Route Logging**: Middleware for logging request and response details.

### Configuration Examples

#### Type Definitions and Resolvers

```typescript
// schema.ts
import { gql } from '@apollo/server';

export const typeDefs = gql`
  type Query {
    hello: String
  }
`;

export const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};
```

#### Context Function

```typescript
// context.ts
import { ExpressContextFunctionArgument } from '@apollo/server/express4';

export const contextFunction = ({ req, res }: ExpressContextFunctionArgument) => {
  return {
    authUser: req.user,
    container: req.container,
  };
};
```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

### Contributing

If you would like to contribute to the project, follow these steps:

1. Fork the repository.
2. Create a new branch: `git checkout -b my-feature`.
3. Make your changes and commit them: `git commit -m 'My new feature'`.
4. Push to the branch: `git push origin my-feature`.
5. Open a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
```

I hope this `README.md` helps to document your project clearly and completely.