Skip to content

Commit

Permalink
chore(release): update monorepo packages versions (#2293)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
theguild-bot and github-actions[bot] authored Aug 26, 2024
1 parent 3c6a7b7 commit a69b847
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 105 deletions.
5 changes: 0 additions & 5 deletions .changeset/@envelop_generic-auth-2281-dependencies.md

This file was deleted.

97 changes: 0 additions & 97 deletions .changeset/sweet-apples-confess.md

This file was deleted.

105 changes: 105 additions & 0 deletions packages/plugins/extended-validation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,110 @@
# @envelop/extended-validation

## 4.1.0

### Minor Changes

- [#2281](https://github.com/n1ru4l/envelop/pull/2281)
[`70d4d7a`](https://github.com/n1ru4l/envelop/commit/70d4d7a1fc359315e50704e52f96d98ba1506575)
Thanks [@UserType;](https://github.com/UserType;)! - Refactor Generic Auth plugin;

- [BREAKING] - Now `@auth` directive is renamed to `@authenticated`. If you want to keep the old
name you can configure the plugin to use the old name.

```ts
useGenericAuth({
// ...
authDirectiveName: 'auth'
})
```

- [BREAKING] - Now `directiveOrExtensionFieldName` is renamed to `authDirectiveName`.

```diff
useGenericAuth({
// ...
- directiveOrExtensionFieldName: 'auth',
+ authDirectiveName: 'auth',
});
```

- Now auth directives support `OBJECT` and `INTERFACE` locations, so you can use the auth
directive on types as well.

```graphql
directive @authenticated on OBJECT | INTERFACE
type User @authenticated {
id: ID!
name: String!
}
```

- `validateUser` function does not receive `fieldAuthDirectiveNode` and `fieldAuthExtension`
anymore. Instead, it takes `fieldAuthArgs` which is an object that contains the arguments of the
auth directive or extension. So you don't need to parse the arguments manually anymore.

```ts
const validateUser: ValidateUserFn = params => {
if (!params.fieldAuthArgs.roles.includes('admin')) {
return createUnauthorizedError(params)
}
}
```

- `validateUser`'s `objectType` parameter is now renamed to `parentType`. And it takes the
original composite type instead of the `GraphQLObjectType` instance. Now it can be
`GraphQLInterfaceType` as well.
- `validateUser`'s current parameters are now;

```ts
export type ValidateUserFnParams<UserType> = {
/** The user object. */
/** The field node from the operation that is being validated. */
fieldNode: FieldNode
/** The parent type which has the field that is being validated. */
parentType: GraphQLObjectType | GraphQLInterfaceType
/** The auth directive arguments for the type */
typeAuthArgs?: Record<string, any>
/** The directives for the type */
typeDirectives?: ReturnType<typeof getDirectiveExtensions>
/** Scopes that type requires */
typeScopes?: string[][]
/** Policies that type requires */
typePolicies?: string[][]
/** The object field */
field: GraphQLField<any, any>
/** The auth directive arguments for the field */
fieldAuthArgs?: Record<string, any>
/** The directives for the field */
fieldDirectives?: ReturnType<typeof getDirectiveExtensions>
/** Scopes that field requires */
fieldScopes?: string[][]
/** Policies that field requires */
fieldPolicies?: string[][]
/** Extracted scopes from the user object */
userScopes: string[]
/** Policies for the user */
userPolicies: string[]
/** The args passed to the execution function (including operation context and variables) **/
executionArgs: ExecutionArgs
/** Resolve path */
path: ReadonlyArray<string | number>
}
```

- New directives for role-based auth are added `@requiresScopes` and `@policy` for more granular
control over the auth logic.

```graphql
directive @requiresScopes(scopes: [String!]!) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @policy(policy: String!) on OBJECT | INTERFACE | FIELD_DEFINITION
```

Check README for more information.

## 4.0.0

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/extended-validation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envelop/extended-validation",
"version": "4.0.0",
"version": "4.1.0",
"type": "module",
"repository": {
"type": "git",
Expand Down
117 changes: 117 additions & 0 deletions packages/plugins/generic-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,122 @@
# @envelop/generic-auth

## 8.0.0

### Major Changes

- [#2281](https://github.com/n1ru4l/envelop/pull/2281)
[`70d4d7a`](https://github.com/n1ru4l/envelop/commit/70d4d7a1fc359315e50704e52f96d98ba1506575)
Thanks [@UserType;](https://github.com/UserType;)! - Refactor Generic Auth plugin;

- [BREAKING] - Now `@auth` directive is renamed to `@authenticated`. If you want to keep the old
name you can configure the plugin to use the old name.

```ts
useGenericAuth({
// ...
authDirectiveName: 'auth'
})
```

- [BREAKING] - Now `directiveOrExtensionFieldName` is renamed to `authDirectiveName`.

```diff
useGenericAuth({
// ...
- directiveOrExtensionFieldName: 'auth',
+ authDirectiveName: 'auth',
});
```

- Now auth directives support `OBJECT` and `INTERFACE` locations, so you can use the auth
directive on types as well.

```graphql
directive @authenticated on OBJECT | INTERFACE
type User @authenticated {
id: ID!
name: String!
}
```

- `validateUser` function does not receive `fieldAuthDirectiveNode` and `fieldAuthExtension`
anymore. Instead, it takes `fieldAuthArgs` which is an object that contains the arguments of the
auth directive or extension. So you don't need to parse the arguments manually anymore.

```ts
const validateUser: ValidateUserFn = params => {
if (!params.fieldAuthArgs.roles.includes('admin')) {
return createUnauthorizedError(params)
}
}
```

- `validateUser`'s `objectType` parameter is now renamed to `parentType`. And it takes the
original composite type instead of the `GraphQLObjectType` instance. Now it can be
`GraphQLInterfaceType` as well.
- `validateUser`'s current parameters are now;

```ts
export type ValidateUserFnParams<UserType> = {
/** The user object. */
/** The field node from the operation that is being validated. */
fieldNode: FieldNode
/** The parent type which has the field that is being validated. */
parentType: GraphQLObjectType | GraphQLInterfaceType
/** The auth directive arguments for the type */
typeAuthArgs?: Record<string, any>
/** The directives for the type */
typeDirectives?: ReturnType<typeof getDirectiveExtensions>
/** Scopes that type requires */
typeScopes?: string[][]
/** Policies that type requires */
typePolicies?: string[][]
/** The object field */
field: GraphQLField<any, any>
/** The auth directive arguments for the field */
fieldAuthArgs?: Record<string, any>
/** The directives for the field */
fieldDirectives?: ReturnType<typeof getDirectiveExtensions>
/** Scopes that field requires */
fieldScopes?: string[][]
/** Policies that field requires */
fieldPolicies?: string[][]
/** Extracted scopes from the user object */
userScopes: string[]
/** Policies for the user */
userPolicies: string[]
/** The args passed to the execution function (including operation context and variables) **/
executionArgs: ExecutionArgs
/** Resolve path */
path: ReadonlyArray<string | number>
}
```

- New directives for role-based auth are added `@requiresScopes` and `@policy` for more granular
control over the auth logic.

```graphql
directive @requiresScopes(scopes: [String!]!) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @policy(policy: String!) on OBJECT | INTERFACE | FIELD_DEFINITION
```

Check README for more information.

### Patch Changes

- [#2281](https://github.com/n1ru4l/envelop/pull/2281)
[`70d4d7a`](https://github.com/n1ru4l/envelop/commit/70d4d7a1fc359315e50704e52f96d98ba1506575)
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
- Updated dependency
[`@graphql-tools/utils@^10.5.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.5.1)
(from `^10.0.6`, in `dependencies`)
- Updated dependencies
[[`70d4d7a`](https://github.com/n1ru4l/envelop/commit/70d4d7a1fc359315e50704e52f96d98ba1506575)]:
- @envelop/extended-validation@4.1.0

## 7.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/generic-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envelop/generic-auth",
"version": "7.0.0",
"version": "8.0.0",
"type": "module",
"repository": {
"type": "git",
Expand Down Expand Up @@ -51,7 +51,7 @@
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"@envelop/extended-validation": "^4.0.0",
"@envelop/extended-validation": "^4.1.0",
"@graphql-tools/utils": "^10.5.1",
"tslib": "^2.5.0"
},
Expand Down

0 comments on commit a69b847

Please sign in to comment.