Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Sep 8, 2023
1 parent d949976 commit 65dfbe9
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 857 deletions.
654 changes: 45 additions & 609 deletions packages/deno/packages/core/builder.ts

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions packages/deno/packages/core/refs/input-object.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions packages/deno/packages/core/types/builder-options.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions packages/deno/packages/plugin-add-graphql/schema-builder.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions packages/deno/packages/plugin-scope-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ For example, if you want to re-throw errors thrown by authorization functions yo
writeing a custom `unauthorizedError` callback like this:

```typescript
import SchemaBuilder, { AuthFailure, AuthScopeFailureType } from '@pothos/core';
import SchemaBuilder from '@pothos/core';
import ScopeAuthPlugin, { AuthFailure, AuthScopeFailureType } from '@pothos/plugin-scope-auth';

// Find the first error and re-throw it
function throwFirstError(failure: AuthFailure) {
Expand All @@ -380,7 +381,7 @@ function throwFirstError(failure: AuthFailure) {
failure.kind === AuthScopeFailureType.AllAuthScopes
) {
for (const child of failure.failures) {
throwFirstError(child, recursive);
throwFirstError(child);
}
}
}
Expand All @@ -397,7 +398,7 @@ const builder = new SchemaBuilder<{
// throw an error if it's found
throwFirstError(result.failure);
// throw a fallback error if no error was found
new Error(`Not authorized`);
return new Error(`Not authorized`);
},
},
plugins: [ScopeAuthPlugin],
Expand Down Expand Up @@ -578,6 +579,28 @@ above example requires a request to have either the `employee` or `deferredScope
`public` scope. `$any` and `$all` each take a scope map as their parameters, and can be nested
inside each other.

You can change the default strategy used for top level auth scopes by setting the `defaultStrategy`
option in the builder (defaults to `any`):

```typescript
const builder = new SchemaBuilder<{
Context: {
user: User | null;
};
AuthScopes: {
loggedIn: boolean;
};
}>({
plugins: [ScopeAuthPlugin],
scopeAuthOptions: {
defaultStrategy: 'all',
},
authScopes: async (context) => ({
loggedIn: !!context.user,
}),
});
```

### Auth that depends on parent value

For cases where the required scopes depend on the value of the requested resource you can use a
Expand Down
6 changes: 4 additions & 2 deletions packages/deno/packages/plugin-scope-auth/request-cache.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/deno/packages/plugin-scope-auth/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions packages/deno/packages/plugin-simple-objects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ContactInfo = builder.simpleObject('ContactInfo', {
email: t.string({
nullable: false,
}),
phoneNUmber: t.string({
phoneNumber: t.string({
nullable: true,
}),
}),
Expand All @@ -49,23 +49,26 @@ const Node = builder.simpleInterface('Node', {
}),
});

const UserType = builder.simpleObject('User', {
interfaces: [Node],
fields: (t) => ({
firstName: t.string(),
lastName: t.string(),
contactInfo: t.field({
type: ContactInfo,
nullable: false,
const UserType = builder.simpleObject(
'User',
{
interfaces: [Node],
fields: (t) => ({
firstName: t.string(),
lastName: t.string(),
contactInfo: t.field({
type: ContactInfo,
nullable: false,
}),
}),
}),
// You can add aditional fields with resolvers with a third fields argument
},
// You can add additional fields with resolvers with a third fields argument
(t) => ({
fullName: t.string({
resolve: (user) => `${user.firstName} ${user.lastName}`,
}),
})
});
}),
);

builder.queryType({
fields: (t) => ({
Expand All @@ -81,7 +84,7 @@ builder.queryType({
lastName: 'Organa',
contactInfo: {
email: 'leia@example.com',
phoneNUmber: null,
phoneNumber: null,
},
};
},
Expand Down
13 changes: 2 additions & 11 deletions packages/deno/packages/plugin-simple-objects/global-types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions packages/deno/packages/plugin-simple-objects/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions packages/plugin-complexity/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ type Query {

exports[`simple objects example schema > negative limits > negative breadth 1`] = `
{
"data": null,
"data": {
"hero": null,
},
"errors": [
[GraphQLError: Query exceeds maximum breadth (breadth: 2, max: -1)],
],
Expand All @@ -128,7 +130,9 @@ exports[`simple objects example schema > negative limits > negative breadth 1`]

exports[`simple objects example schema > negative limits > negative complexity 1`] = `
{
"data": null,
"data": {
"hero": null,
},
"errors": [
[GraphQLError: Query exceeds maximum complexity (complexity: 2, max: -1)],
],
Expand All @@ -137,7 +141,9 @@ exports[`simple objects example schema > negative limits > negative complexity 1

exports[`simple objects example schema > negative limits > negative depth 1`] = `
{
"data": null,
"data": {
"hero": null,
},
"errors": [
[GraphQLError: Query exceeds maximum depth (depth: 2, max: -1)],
],
Expand Down Expand Up @@ -473,7 +479,9 @@ exports[`simple objects example schema > queries > valid query 1`] = `

exports[`simple objects example schema > zero limits > zero breadth 1`] = `
{
"data": null,
"data": {
"hero": null,
},
"errors": [
[GraphQLError: Query exceeds maximum breadth (breadth: 2, max: 0)],
],
Expand All @@ -482,7 +490,9 @@ exports[`simple objects example schema > zero limits > zero breadth 1`] = `

exports[`simple objects example schema > zero limits > zero complexity 1`] = `
{
"data": null,
"data": {
"hero": null,
},
"errors": [
[GraphQLError: Query exceeds maximum complexity (complexity: 2, max: 0)],
],
Expand All @@ -491,7 +501,9 @@ exports[`simple objects example schema > zero limits > zero complexity 1`] = `

exports[`simple objects example schema > zero limits > zero depth 1`] = `
{
"data": null,
"data": {
"hero": null,
},
"errors": [
[GraphQLError: Query exceeds maximum depth (depth: 2, max: 0)],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ input IntFilter {
}
type Mutation {
createPosts(data: [PostCreateInput!]!): [Post!]!
createUser(data: UserCreateInput!): User!
updatePost(data: PostUpdateInput!, id: Int!): Post!
createPosts(data: [PostCreateInput!]!): [Post!]
createUser(data: UserCreateInput!): User
updatePost(data: PostUpdateInput!, id: Int!): Post
}
enum OrderBy {
Expand All @@ -36,8 +36,8 @@ enum OrderBy {
}
type Post {
author: User!
id: ID!
author: User
id: ID
}
input PostCreateInput {
Expand Down Expand Up @@ -96,10 +96,10 @@ input StringListFilter {
}
type User {
email: String!
id: ID!
email: String
id: ID
name: String
posts: [Post!]!
posts: [Post!]
}
input UserCreateInput {
Expand Down
Loading

0 comments on commit 65dfbe9

Please sign in to comment.