Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mohab-sameh authored Dec 21, 2023
1 parent 6d90ef2 commit 96caca4
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions codemods/redwoodjs/core/4/auth-decoder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Auth Decoder

## Description

This codemod for RedwoodJS v4 automatically inserts an `authDecoder` property into the `createGraphQLHandler` call if it's not already present. It also adds an import statement for `authDecoder` from `@redwoodjs/auth-auth0-api` at the beginning of the file, ensuring that the necessary functionality for authentication is correctly integrated.

## Example

### Before

```TypeScript
import { createGraphQLHandler } from '@redwoodjs/graphql-server';

import directives from 'src/directives/**/*.{js,ts}';
import sdls from 'src/graphql/**/*.sdl.{js,ts}';
import services from 'src/services/**/*.{js,ts}';

import { db } from 'src/lib/db';
import { logger } from 'src/lib/logger';

export const handler = createGraphQLHandler({
loggerConfig: { logger, options: {} },
directives,
sdls,
services,
onException: () => {
// Disconnect from your database with an unhandled exception.
db.$disconnect();
},
});
```

### After

```TypeScript
import { authDecoder } from '@redwoodjs/auth-auth0-api';
import { createGraphQLHandler } from '@redwoodjs/graphql-server';

import directives from 'src/directives/**/*.{js,ts}';
import sdls from 'src/graphql/**/*.sdl.{js,ts}';
import services from 'src/services/**/*.{js,ts}';

import { db } from 'src/lib/db';
import { logger } from 'src/lib/logger';

export const handler = createGraphQLHandler({
authDecoder: authDecoder,
loggerConfig: { logger, options: {} },
directives,
sdls,
services,

onException: () => {
// Disconnect from your database with an unhandled exception.
db.$disconnect();
}
});
```

## Applicability Criteria

RedwoodJS < v4.0.0

## Other Metadata

### Codemod Version

v1.0.0

### Change Mode

**Assistive**: The automation partially completes changes. Human involvement is needed to make changes ready to be pushed and merged.

### **Codemod Engine**

[jscodeshift](https://github.com/facebook/jscodeshift)

### Estimated Time Saving

~5 minutes per occurrence

### Owner

[Rajasegar Chandran](https://github.com/rajasegar)

0 comments on commit 96caca4

Please sign in to comment.