diff --git a/.changeset/happy-insects-give.md b/.changeset/happy-insects-give.md new file mode 100644 index 00000000000..d5807220202 --- /dev/null +++ b/.changeset/happy-insects-give.md @@ -0,0 +1,14 @@ +--- +'@keystone-next/example-auth': patch +'@keystone-next/examples-app-basic': patch +'@keystone-next/example-ecommerce': patch +'keystone-next-app': patch +'@keystone-next/example-roles': patch +'@keystone-next/example-extend-graphql-schema': patch +'@keystone-next/example-testing': patch +'@keystone-next/example-with-auth': patch +'@keystone-next/auth': patch +'@keystone-next/keystone': patch +--- + +Updated dependencies to use `mergeSchemas` from `@graphql-tools/schema`, rather than its old location in `@graphql-tools/merge`. You might see a reordering of the contents of your `graphql.schema` file. diff --git a/examples-staging/auth/schema.graphql b/examples-staging/auth/schema.graphql index ca9b48a37b4..d2c5409d59e 100644 --- a/examples-staging/auth/schema.graphql +++ b/examples-staging/auth/schema.graphql @@ -1,3 +1,50 @@ +input CreateInitialUserInput { + name: String + email: String + password: String +} + +type Mutation { + createInitialUser( + data: CreateInitialUserInput! + ): UserAuthenticationWithPasswordSuccess! + authenticateUserWithPassword( + email: String! + password: String! + ): UserAuthenticationWithPasswordResult! + createUser(data: UserCreateInput!): User + createUsers(data: [UserCreateInput!]!): [User] + updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User + updateUsers(data: [UserUpdateArgs!]!): [User] + deleteUser(where: UserWhereUniqueInput!): User + deleteUsers(where: [UserWhereUniqueInput!]!): [User] + endSession: Boolean! +} + +union AuthenticatedItem = User + +union UserAuthenticationWithPasswordResult = + UserAuthenticationWithPasswordSuccess + | UserAuthenticationWithPasswordFailure + +type UserAuthenticationWithPasswordSuccess { + sessionToken: String! + item: User! +} + +type UserAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type User { id: ID! name: String @@ -113,54 +160,8 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createUser(data: UserCreateInput!): User - createUsers(data: [UserCreateInput!]!): [User] - updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User - updateUsers(data: [UserUpdateArgs!]!): [User] - deleteUser(where: UserWhereUniqueInput!): User - deleteUsers(where: [UserWhereUniqueInput!]!): [User] - authenticateUserWithPassword( - email: String! - password: String! - ): UserAuthenticationWithPasswordResult! - createInitialUser( - data: CreateInitialUserInput! - ): UserAuthenticationWithPasswordSuccess! - endSession: Boolean! -} - -union AuthenticatedItem = User - -union UserAuthenticationWithPasswordResult = - UserAuthenticationWithPasswordSuccess - | UserAuthenticationWithPasswordFailure - -type UserAuthenticationWithPasswordSuccess { - sessionToken: String! - item: User! -} - -type UserAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialUserInput { - name: String - email: String - password: String -} - type Query { + authenticatedItem: AuthenticatedItem users( where: UserWhereInput! = {} orderBy: [UserOrderByInput!]! = [] @@ -169,7 +170,6 @@ type Query { ): [User!] user(where: UserWhereUniqueInput!): User usersCount(where: UserWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! } diff --git a/examples-staging/basic/package.json b/examples-staging/basic/package.json index 538898ba669..9ddd282d815 100644 --- a/examples-staging/basic/package.json +++ b/examples-staging/basic/package.json @@ -10,7 +10,6 @@ }, "dependencies": { "@babel/runtime": "^7.14.8", - "@graphql-tools/merge": "^7.0.0", "@keystone-next/auth": "^30.0.0", "@keystone-next/document-renderer": "^4.0.0", "@keystone-next/fields": "^13.0.0", diff --git a/examples-staging/basic/schema.graphql b/examples-staging/basic/schema.graphql index babeb297c2f..9800f4b99ce 100644 --- a/examples-staging/basic/schema.graphql +++ b/examples-staging/basic/schema.graphql @@ -1,3 +1,71 @@ +type RandomNumber { + number: Int + generatedAt: Int +} + +type Mutation { + createRandomPosts: [Post!]! + createInitialUser( + data: CreateInitialUserInput! + ): UserAuthenticationWithPasswordSuccess! + authenticateUserWithPassword( + email: String! + password: String! + ): UserAuthenticationWithPasswordResult! + createUser(data: UserCreateInput!): User + createUsers(data: [UserCreateInput!]!): [User] + updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User + updateUsers(data: [UserUpdateArgs!]!): [User] + deleteUser(where: UserWhereUniqueInput!): User + deleteUsers(where: [UserWhereUniqueInput!]!): [User] + createPhoneNumber(data: PhoneNumberCreateInput!): PhoneNumber + createPhoneNumbers(data: [PhoneNumberCreateInput!]!): [PhoneNumber] + updatePhoneNumber( + where: PhoneNumberWhereUniqueInput! + data: PhoneNumberUpdateInput! + ): PhoneNumber + updatePhoneNumbers(data: [PhoneNumberUpdateArgs!]!): [PhoneNumber] + deletePhoneNumber(where: PhoneNumberWhereUniqueInput!): PhoneNumber + deletePhoneNumbers(where: [PhoneNumberWhereUniqueInput!]!): [PhoneNumber] + createPost(data: PostCreateInput!): Post + createPosts(data: [PostCreateInput!]!): [Post] + updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post + updatePosts(data: [PostUpdateArgs!]!): [Post] + deletePost(where: PostWhereUniqueInput!): Post + deletePosts(where: [PostWhereUniqueInput!]!): [Post] + endSession: Boolean! +} + +input CreateInitialUserInput { + name: String + email: String + password: String +} + +union AuthenticatedItem = User + +union UserAuthenticationWithPasswordResult = + UserAuthenticationWithPasswordSuccess + | UserAuthenticationWithPasswordFailure + +type UserAuthenticationWithPasswordSuccess { + sessionToken: String! + item: User! +} + +type UserAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type User { id: ID! name: String @@ -360,75 +428,9 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createUser(data: UserCreateInput!): User - createUsers(data: [UserCreateInput!]!): [User] - updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User - updateUsers(data: [UserUpdateArgs!]!): [User] - deleteUser(where: UserWhereUniqueInput!): User - deleteUsers(where: [UserWhereUniqueInput!]!): [User] - createPhoneNumber(data: PhoneNumberCreateInput!): PhoneNumber - createPhoneNumbers(data: [PhoneNumberCreateInput!]!): [PhoneNumber] - updatePhoneNumber( - where: PhoneNumberWhereUniqueInput! - data: PhoneNumberUpdateInput! - ): PhoneNumber - updatePhoneNumbers(data: [PhoneNumberUpdateArgs!]!): [PhoneNumber] - deletePhoneNumber(where: PhoneNumberWhereUniqueInput!): PhoneNumber - deletePhoneNumbers(where: [PhoneNumberWhereUniqueInput!]!): [PhoneNumber] - createPost(data: PostCreateInput!): Post - createPosts(data: [PostCreateInput!]!): [Post] - updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post - updatePosts(data: [PostUpdateArgs!]!): [Post] - deletePost(where: PostWhereUniqueInput!): Post - deletePosts(where: [PostWhereUniqueInput!]!): [Post] - authenticateUserWithPassword( - email: String! - password: String! - ): UserAuthenticationWithPasswordResult! - createInitialUser( - data: CreateInitialUserInput! - ): UserAuthenticationWithPasswordSuccess! - createRandomPosts: [Post!]! - endSession: Boolean! -} - -union AuthenticatedItem = User - -union UserAuthenticationWithPasswordResult = - UserAuthenticationWithPasswordSuccess - | UserAuthenticationWithPasswordFailure - -type UserAuthenticationWithPasswordSuccess { - sessionToken: String! - item: User! -} - -type UserAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialUserInput { - name: String - email: String - password: String -} - -type RandomNumber { - number: Int - generatedAt: Int -} - type Query { + randomNumber: RandomNumber + authenticatedItem: AuthenticatedItem users( where: UserWhereInput! = {} orderBy: [UserOrderByInput!]! = [] @@ -453,8 +455,6 @@ type Query { ): [Post!] post(where: PostWhereUniqueInput!): Post postsCount(where: PostWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem - randomNumber: RandomNumber keystone: KeystoneMeta! } diff --git a/examples-staging/ecommerce/schema.graphql b/examples-staging/ecommerce/schema.graphql index 049b70e103e..4b3d0b5cc08 100644 --- a/examples-staging/ecommerce/schema.graphql +++ b/examples-staging/ecommerce/schema.graphql @@ -1,3 +1,136 @@ +type Mutation { + addToCart(productId: ID): CartItem + checkout(token: String!): Order + sendUserPasswordResetLink(email: String!): SendUserPasswordResetLinkResult + redeemUserPasswordResetToken( + email: String! + token: String! + password: String! + ): RedeemUserPasswordResetTokenResult + createInitialUser( + data: CreateInitialUserInput! + ): UserAuthenticationWithPasswordSuccess! + authenticateUserWithPassword( + email: String! + password: String! + ): UserAuthenticationWithPasswordResult! + createUser(data: UserCreateInput!): User + createUsers(data: [UserCreateInput!]!): [User] + updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User + updateUsers(data: [UserUpdateArgs!]!): [User] + deleteUser(where: UserWhereUniqueInput!): User + deleteUsers(where: [UserWhereUniqueInput!]!): [User] + createProduct(data: ProductCreateInput!): Product + createProducts(data: [ProductCreateInput!]!): [Product] + updateProduct( + where: ProductWhereUniqueInput! + data: ProductUpdateInput! + ): Product + updateProducts(data: [ProductUpdateArgs!]!): [Product] + deleteProduct(where: ProductWhereUniqueInput!): Product + deleteProducts(where: [ProductWhereUniqueInput!]!): [Product] + createProductImage(data: ProductImageCreateInput!): ProductImage + createProductImages(data: [ProductImageCreateInput!]!): [ProductImage] + updateProductImage( + where: ProductImageWhereUniqueInput! + data: ProductImageUpdateInput! + ): ProductImage + updateProductImages(data: [ProductImageUpdateArgs!]!): [ProductImage] + deleteProductImage(where: ProductImageWhereUniqueInput!): ProductImage + deleteProductImages(where: [ProductImageWhereUniqueInput!]!): [ProductImage] + createCartItem(data: CartItemCreateInput!): CartItem + createCartItems(data: [CartItemCreateInput!]!): [CartItem] + updateCartItem( + where: CartItemWhereUniqueInput! + data: CartItemUpdateInput! + ): CartItem + updateCartItems(data: [CartItemUpdateArgs!]!): [CartItem] + deleteCartItem(where: CartItemWhereUniqueInput!): CartItem + deleteCartItems(where: [CartItemWhereUniqueInput!]!): [CartItem] + createOrderItem(data: OrderItemCreateInput!): OrderItem + createOrderItems(data: [OrderItemCreateInput!]!): [OrderItem] + updateOrderItem( + where: OrderItemWhereUniqueInput! + data: OrderItemUpdateInput! + ): OrderItem + updateOrderItems(data: [OrderItemUpdateArgs!]!): [OrderItem] + deleteOrderItem(where: OrderItemWhereUniqueInput!): OrderItem + deleteOrderItems(where: [OrderItemWhereUniqueInput!]!): [OrderItem] + createOrder(data: OrderCreateInput!): Order + createOrders(data: [OrderCreateInput!]!): [Order] + updateOrder(where: OrderWhereUniqueInput!, data: OrderUpdateInput!): Order + updateOrders(data: [OrderUpdateArgs!]!): [Order] + deleteOrder(where: OrderWhereUniqueInput!): Order + deleteOrders(where: [OrderWhereUniqueInput!]!): [Order] + createRole(data: RoleCreateInput!): Role + createRoles(data: [RoleCreateInput!]!): [Role] + updateRole(where: RoleWhereUniqueInput!, data: RoleUpdateInput!): Role + updateRoles(data: [RoleUpdateArgs!]!): [Role] + deleteRole(where: RoleWhereUniqueInput!): Role + deleteRoles(where: [RoleWhereUniqueInput!]!): [Role] + endSession: Boolean! +} + +type SendUserPasswordResetLinkResult { + code: PasswordResetRequestErrorCode! + message: String! +} + +enum PasswordResetRequestErrorCode { + IDENTITY_NOT_FOUND + MULTIPLE_IDENTITY_MATCHES +} + +type ValidateUserPasswordResetTokenResult { + code: PasswordResetRedemptionErrorCode! + message: String! +} + +type RedeemUserPasswordResetTokenResult { + code: PasswordResetRedemptionErrorCode! + message: String! +} + +enum PasswordResetRedemptionErrorCode { + FAILURE + IDENTITY_NOT_FOUND + MULTIPLE_IDENTITY_MATCHES + TOKEN_NOT_SET + TOKEN_MISMATCH + TOKEN_EXPIRED + TOKEN_REDEEMED +} + +input CreateInitialUserInput { + name: String + email: String + password: String +} + +union AuthenticatedItem = User + +union UserAuthenticationWithPasswordResult = + UserAuthenticationWithPasswordSuccess + | UserAuthenticationWithPasswordFailure + +type UserAuthenticationWithPasswordSuccess { + sessionToken: String! + item: User! +} + +type UserAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type User { id: ID! name: String @@ -708,140 +841,12 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createUser(data: UserCreateInput!): User - createUsers(data: [UserCreateInput!]!): [User] - updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User - updateUsers(data: [UserUpdateArgs!]!): [User] - deleteUser(where: UserWhereUniqueInput!): User - deleteUsers(where: [UserWhereUniqueInput!]!): [User] - createProduct(data: ProductCreateInput!): Product - createProducts(data: [ProductCreateInput!]!): [Product] - updateProduct( - where: ProductWhereUniqueInput! - data: ProductUpdateInput! - ): Product - updateProducts(data: [ProductUpdateArgs!]!): [Product] - deleteProduct(where: ProductWhereUniqueInput!): Product - deleteProducts(where: [ProductWhereUniqueInput!]!): [Product] - createProductImage(data: ProductImageCreateInput!): ProductImage - createProductImages(data: [ProductImageCreateInput!]!): [ProductImage] - updateProductImage( - where: ProductImageWhereUniqueInput! - data: ProductImageUpdateInput! - ): ProductImage - updateProductImages(data: [ProductImageUpdateArgs!]!): [ProductImage] - deleteProductImage(where: ProductImageWhereUniqueInput!): ProductImage - deleteProductImages(where: [ProductImageWhereUniqueInput!]!): [ProductImage] - createCartItem(data: CartItemCreateInput!): CartItem - createCartItems(data: [CartItemCreateInput!]!): [CartItem] - updateCartItem( - where: CartItemWhereUniqueInput! - data: CartItemUpdateInput! - ): CartItem - updateCartItems(data: [CartItemUpdateArgs!]!): [CartItem] - deleteCartItem(where: CartItemWhereUniqueInput!): CartItem - deleteCartItems(where: [CartItemWhereUniqueInput!]!): [CartItem] - createOrderItem(data: OrderItemCreateInput!): OrderItem - createOrderItems(data: [OrderItemCreateInput!]!): [OrderItem] - updateOrderItem( - where: OrderItemWhereUniqueInput! - data: OrderItemUpdateInput! - ): OrderItem - updateOrderItems(data: [OrderItemUpdateArgs!]!): [OrderItem] - deleteOrderItem(where: OrderItemWhereUniqueInput!): OrderItem - deleteOrderItems(where: [OrderItemWhereUniqueInput!]!): [OrderItem] - createOrder(data: OrderCreateInput!): Order - createOrders(data: [OrderCreateInput!]!): [Order] - updateOrder(where: OrderWhereUniqueInput!, data: OrderUpdateInput!): Order - updateOrders(data: [OrderUpdateArgs!]!): [Order] - deleteOrder(where: OrderWhereUniqueInput!): Order - deleteOrders(where: [OrderWhereUniqueInput!]!): [Order] - createRole(data: RoleCreateInput!): Role - createRoles(data: [RoleCreateInput!]!): [Role] - updateRole(where: RoleWhereUniqueInput!, data: RoleUpdateInput!): Role - updateRoles(data: [RoleUpdateArgs!]!): [Role] - deleteRole(where: RoleWhereUniqueInput!): Role - deleteRoles(where: [RoleWhereUniqueInput!]!): [Role] - authenticateUserWithPassword( - email: String! - password: String! - ): UserAuthenticationWithPasswordResult! - createInitialUser( - data: CreateInitialUserInput! - ): UserAuthenticationWithPasswordSuccess! - sendUserPasswordResetLink(email: String!): SendUserPasswordResetLinkResult - redeemUserPasswordResetToken( +type Query { + validateUserPasswordResetToken( email: String! token: String! - password: String! - ): RedeemUserPasswordResetTokenResult - addToCart(productId: ID): CartItem - checkout(token: String!): Order - endSession: Boolean! -} - -union AuthenticatedItem = User - -union UserAuthenticationWithPasswordResult = - UserAuthenticationWithPasswordSuccess - | UserAuthenticationWithPasswordFailure - -type UserAuthenticationWithPasswordSuccess { - sessionToken: String! - item: User! -} - -type UserAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialUserInput { - name: String - email: String - password: String -} - -type SendUserPasswordResetLinkResult { - code: PasswordResetRequestErrorCode! - message: String! -} - -enum PasswordResetRequestErrorCode { - IDENTITY_NOT_FOUND - MULTIPLE_IDENTITY_MATCHES -} - -type ValidateUserPasswordResetTokenResult { - code: PasswordResetRedemptionErrorCode! - message: String! -} - -type RedeemUserPasswordResetTokenResult { - code: PasswordResetRedemptionErrorCode! - message: String! -} - -enum PasswordResetRedemptionErrorCode { - FAILURE - IDENTITY_NOT_FOUND - MULTIPLE_IDENTITY_MATCHES - TOKEN_NOT_SET - TOKEN_MISMATCH - TOKEN_EXPIRED - TOKEN_REDEEMED -} - -type Query { + ): ValidateUserPasswordResetTokenResult + authenticatedItem: AuthenticatedItem users( where: UserWhereInput! = {} orderBy: [UserOrderByInput!]! = [] @@ -898,11 +903,6 @@ type Query { ): [Role!] role(where: RoleWhereUniqueInput!): Role rolesCount(where: RoleWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem - validateUserPasswordResetToken( - email: String! - token: String! - ): ValidateUserPasswordResetTokenResult keystone: KeystoneMeta! } diff --git a/examples-staging/graphql-api-endpoint/schema.graphql b/examples-staging/graphql-api-endpoint/schema.graphql index b2964a361f8..1203d46c607 100644 --- a/examples-staging/graphql-api-endpoint/schema.graphql +++ b/examples-staging/graphql-api-endpoint/schema.graphql @@ -1,3 +1,62 @@ +input CreateInitialUserInput { + name: String + email: String + password: String +} + +type Mutation { + createInitialUser( + data: CreateInitialUserInput! + ): UserAuthenticationWithPasswordSuccess! + authenticateUserWithPassword( + email: String! + password: String! + ): UserAuthenticationWithPasswordResult! + createUser(data: UserCreateInput!): User + createUsers(data: [UserCreateInput!]!): [User] + updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User + updateUsers(data: [UserUpdateArgs!]!): [User] + deleteUser(where: UserWhereUniqueInput!): User + deleteUsers(where: [UserWhereUniqueInput!]!): [User] + createPost(data: PostCreateInput!): Post + createPosts(data: [PostCreateInput!]!): [Post] + updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post + updatePosts(data: [PostUpdateArgs!]!): [Post] + deletePost(where: PostWhereUniqueInput!): Post + deletePosts(where: [PostWhereUniqueInput!]!): [Post] + createTag(data: TagCreateInput!): Tag + createTags(data: [TagCreateInput!]!): [Tag] + updateTag(where: TagWhereUniqueInput!, data: TagUpdateInput!): Tag + updateTags(data: [TagUpdateArgs!]!): [Tag] + deleteTag(where: TagWhereUniqueInput!): Tag + deleteTags(where: [TagWhereUniqueInput!]!): [Tag] + endSession: Boolean! +} + +union AuthenticatedItem = User + +union UserAuthenticationWithPasswordResult = + UserAuthenticationWithPasswordSuccess + | UserAuthenticationWithPasswordFailure + +type UserAuthenticationWithPasswordSuccess { + sessionToken: String! + item: User! +} + +type UserAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type User { id: ID! name: String @@ -288,66 +347,8 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createUser(data: UserCreateInput!): User - createUsers(data: [UserCreateInput!]!): [User] - updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User - updateUsers(data: [UserUpdateArgs!]!): [User] - deleteUser(where: UserWhereUniqueInput!): User - deleteUsers(where: [UserWhereUniqueInput!]!): [User] - createPost(data: PostCreateInput!): Post - createPosts(data: [PostCreateInput!]!): [Post] - updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post - updatePosts(data: [PostUpdateArgs!]!): [Post] - deletePost(where: PostWhereUniqueInput!): Post - deletePosts(where: [PostWhereUniqueInput!]!): [Post] - createTag(data: TagCreateInput!): Tag - createTags(data: [TagCreateInput!]!): [Tag] - updateTag(where: TagWhereUniqueInput!, data: TagUpdateInput!): Tag - updateTags(data: [TagUpdateArgs!]!): [Tag] - deleteTag(where: TagWhereUniqueInput!): Tag - deleteTags(where: [TagWhereUniqueInput!]!): [Tag] - authenticateUserWithPassword( - email: String! - password: String! - ): UserAuthenticationWithPasswordResult! - createInitialUser( - data: CreateInitialUserInput! - ): UserAuthenticationWithPasswordSuccess! - endSession: Boolean! -} - -union AuthenticatedItem = User - -union UserAuthenticationWithPasswordResult = - UserAuthenticationWithPasswordSuccess - | UserAuthenticationWithPasswordFailure - -type UserAuthenticationWithPasswordSuccess { - sessionToken: String! - item: User! -} - -type UserAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialUserInput { - name: String - email: String - password: String -} - type Query { + authenticatedItem: AuthenticatedItem users( where: UserWhereInput! = {} orderBy: [UserOrderByInput!]! = [] @@ -372,7 +373,6 @@ type Query { ): [Tag!] tag(where: TagWhereUniqueInput!): Tag tagsCount(where: TagWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! } diff --git a/examples-staging/roles/schema.graphql b/examples-staging/roles/schema.graphql index b0de2b2351d..ba8201c3db0 100644 --- a/examples-staging/roles/schema.graphql +++ b/examples-staging/roles/schema.graphql @@ -1,3 +1,62 @@ +input CreateInitialPersonInput { + name: String + email: String + password: String +} + +type Mutation { + createInitialPerson( + data: CreateInitialPersonInput! + ): PersonAuthenticationWithPasswordSuccess! + authenticatePersonWithPassword( + email: String! + password: String! + ): PersonAuthenticationWithPasswordResult! + createTodo(data: TodoCreateInput!): Todo + createTodos(data: [TodoCreateInput!]!): [Todo] + updateTodo(where: TodoWhereUniqueInput!, data: TodoUpdateInput!): Todo + updateTodos(data: [TodoUpdateArgs!]!): [Todo] + deleteTodo(where: TodoWhereUniqueInput!): Todo + deleteTodos(where: [TodoWhereUniqueInput!]!): [Todo] + createPerson(data: PersonCreateInput!): Person + createPeople(data: [PersonCreateInput!]!): [Person] + updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person + updatePeople(data: [PersonUpdateArgs!]!): [Person] + deletePerson(where: PersonWhereUniqueInput!): Person + deletePeople(where: [PersonWhereUniqueInput!]!): [Person] + createRole(data: RoleCreateInput!): Role + createRoles(data: [RoleCreateInput!]!): [Role] + updateRole(where: RoleWhereUniqueInput!, data: RoleUpdateInput!): Role + updateRoles(data: [RoleUpdateArgs!]!): [Role] + deleteRole(where: RoleWhereUniqueInput!): Role + deleteRoles(where: [RoleWhereUniqueInput!]!): [Role] + endSession: Boolean! +} + +union AuthenticatedItem = Person + +union PersonAuthenticationWithPasswordResult = + PersonAuthenticationWithPasswordSuccess + | PersonAuthenticationWithPasswordFailure + +type PersonAuthenticationWithPasswordSuccess { + sessionToken: String! + item: Person! +} + +type PersonAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type Todo { id: ID! label: String @@ -304,66 +363,8 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createTodo(data: TodoCreateInput!): Todo - createTodos(data: [TodoCreateInput!]!): [Todo] - updateTodo(where: TodoWhereUniqueInput!, data: TodoUpdateInput!): Todo - updateTodos(data: [TodoUpdateArgs!]!): [Todo] - deleteTodo(where: TodoWhereUniqueInput!): Todo - deleteTodos(where: [TodoWhereUniqueInput!]!): [Todo] - createPerson(data: PersonCreateInput!): Person - createPeople(data: [PersonCreateInput!]!): [Person] - updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person - updatePeople(data: [PersonUpdateArgs!]!): [Person] - deletePerson(where: PersonWhereUniqueInput!): Person - deletePeople(where: [PersonWhereUniqueInput!]!): [Person] - createRole(data: RoleCreateInput!): Role - createRoles(data: [RoleCreateInput!]!): [Role] - updateRole(where: RoleWhereUniqueInput!, data: RoleUpdateInput!): Role - updateRoles(data: [RoleUpdateArgs!]!): [Role] - deleteRole(where: RoleWhereUniqueInput!): Role - deleteRoles(where: [RoleWhereUniqueInput!]!): [Role] - authenticatePersonWithPassword( - email: String! - password: String! - ): PersonAuthenticationWithPasswordResult! - createInitialPerson( - data: CreateInitialPersonInput! - ): PersonAuthenticationWithPasswordSuccess! - endSession: Boolean! -} - -union AuthenticatedItem = Person - -union PersonAuthenticationWithPasswordResult = - PersonAuthenticationWithPasswordSuccess - | PersonAuthenticationWithPasswordFailure - -type PersonAuthenticationWithPasswordSuccess { - sessionToken: String! - item: Person! -} - -type PersonAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialPersonInput { - name: String - email: String - password: String -} - type Query { + authenticatedItem: AuthenticatedItem todos( where: TodoWhereInput! = {} orderBy: [TodoOrderByInput!]! = [] @@ -388,7 +389,6 @@ type Query { ): [Role!] role(where: RoleWhereUniqueInput!): Role rolesCount(where: RoleWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! } diff --git a/examples/extend-graphql-schema/schema.graphql b/examples/extend-graphql-schema/schema.graphql index 24663972619..5268dc2c516 100644 --- a/examples/extend-graphql-schema/schema.graphql +++ b/examples/extend-graphql-schema/schema.graphql @@ -1,3 +1,31 @@ +type Mutation { + """ + Publish a post + """ + publishPost(id: ID!): Post + createPost(data: PostCreateInput!): Post + createPosts(data: [PostCreateInput!]!): [Post] + updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post + updatePosts(data: [PostUpdateArgs!]!): [Post] + deletePost(where: PostWhereUniqueInput!): Post + deletePosts(where: [PostWhereUniqueInput!]!): [Post] + createAuthor(data: AuthorCreateInput!): Author + createAuthors(data: [AuthorCreateInput!]!): [Author] + updateAuthor(where: AuthorWhereUniqueInput!, data: AuthorUpdateInput!): Author + updateAuthors(data: [AuthorUpdateArgs!]!): [Author] + deleteAuthor(where: AuthorWhereUniqueInput!): Author + deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author] +} + +""" + A custom type to represent statistics for a user +""" +type Statistics { + draft: Int + published: Int + latest: Post +} + type Post { id: ID! title: String @@ -207,36 +235,16 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createPost(data: PostCreateInput!): Post - createPosts(data: [PostCreateInput!]!): [Post] - updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post - updatePosts(data: [PostUpdateArgs!]!): [Post] - deletePost(where: PostWhereUniqueInput!): Post - deletePosts(where: [PostWhereUniqueInput!]!): [Post] - createAuthor(data: AuthorCreateInput!): Author - createAuthors(data: [AuthorCreateInput!]!): [Author] - updateAuthor(where: AuthorWhereUniqueInput!, data: AuthorUpdateInput!): Author - updateAuthors(data: [AuthorUpdateArgs!]!): [Author] - deleteAuthor(where: AuthorWhereUniqueInput!): Author - deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author] - +type Query { """ - Publish a post + Return all posts for a user from the last days """ - publishPost(id: ID!): Post -} - -""" - A custom type to represent statistics for a user -""" -type Statistics { - draft: Int - published: Int - latest: Post -} + recentPosts(id: ID!, days: Int! = 7): [Post] -type Query { + """ + Compute statistics for a user + """ + stats(id: ID!): Statistics posts( where: PostWhereInput! = {} orderBy: [PostOrderByInput!]! = [] @@ -253,16 +261,6 @@ type Query { ): [Author!] author(where: AuthorWhereUniqueInput!): Author authorsCount(where: AuthorWhereInput! = {}): Int - - """ - Return all posts for a user from the last days - """ - recentPosts(id: ID!, days: Int! = 7): [Post] - - """ - Compute statistics for a user - """ - stats(id: ID!): Statistics keystone: KeystoneMeta! } diff --git a/examples/testing/schema.graphql b/examples/testing/schema.graphql index 0a1c81d87e6..c6a5ddc8586 100644 --- a/examples/testing/schema.graphql +++ b/examples/testing/schema.graphql @@ -1,3 +1,56 @@ +input CreateInitialPersonInput { + name: String + email: String + password: String +} + +type Mutation { + createInitialPerson( + data: CreateInitialPersonInput! + ): PersonAuthenticationWithPasswordSuccess! + authenticatePersonWithPassword( + email: String! + password: String! + ): PersonAuthenticationWithPasswordResult! + createTask(data: TaskCreateInput!): Task + createTasks(data: [TaskCreateInput!]!): [Task] + updateTask(where: TaskWhereUniqueInput!, data: TaskUpdateInput!): Task + updateTasks(data: [TaskUpdateArgs!]!): [Task] + deleteTask(where: TaskWhereUniqueInput!): Task + deleteTasks(where: [TaskWhereUniqueInput!]!): [Task] + createPerson(data: PersonCreateInput!): Person + createPeople(data: [PersonCreateInput!]!): [Person] + updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person + updatePeople(data: [PersonUpdateArgs!]!): [Person] + deletePerson(where: PersonWhereUniqueInput!): Person + deletePeople(where: [PersonWhereUniqueInput!]!): [Person] + endSession: Boolean! +} + +union AuthenticatedItem = Person + +union PersonAuthenticationWithPasswordResult = + PersonAuthenticationWithPasswordSuccess + | PersonAuthenticationWithPasswordFailure + +type PersonAuthenticationWithPasswordSuccess { + sessionToken: String! + item: Person! +} + +type PersonAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type Task { id: ID! label: String @@ -225,60 +278,8 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createTask(data: TaskCreateInput!): Task - createTasks(data: [TaskCreateInput!]!): [Task] - updateTask(where: TaskWhereUniqueInput!, data: TaskUpdateInput!): Task - updateTasks(data: [TaskUpdateArgs!]!): [Task] - deleteTask(where: TaskWhereUniqueInput!): Task - deleteTasks(where: [TaskWhereUniqueInput!]!): [Task] - createPerson(data: PersonCreateInput!): Person - createPeople(data: [PersonCreateInput!]!): [Person] - updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person - updatePeople(data: [PersonUpdateArgs!]!): [Person] - deletePerson(where: PersonWhereUniqueInput!): Person - deletePeople(where: [PersonWhereUniqueInput!]!): [Person] - authenticatePersonWithPassword( - email: String! - password: String! - ): PersonAuthenticationWithPasswordResult! - createInitialPerson( - data: CreateInitialPersonInput! - ): PersonAuthenticationWithPasswordSuccess! - endSession: Boolean! -} - -union AuthenticatedItem = Person - -union PersonAuthenticationWithPasswordResult = - PersonAuthenticationWithPasswordSuccess - | PersonAuthenticationWithPasswordFailure - -type PersonAuthenticationWithPasswordSuccess { - sessionToken: String! - item: Person! -} - -type PersonAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialPersonInput { - name: String - email: String - password: String -} - type Query { + authenticatedItem: AuthenticatedItem tasks( where: TaskWhereInput! = {} orderBy: [TaskOrderByInput!]! = [] @@ -295,7 +296,6 @@ type Query { ): [Person!] person(where: PersonWhereUniqueInput!): Person peopleCount(where: PersonWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! } diff --git a/examples/with-auth/schema.graphql b/examples/with-auth/schema.graphql index 0a1c81d87e6..c6a5ddc8586 100644 --- a/examples/with-auth/schema.graphql +++ b/examples/with-auth/schema.graphql @@ -1,3 +1,56 @@ +input CreateInitialPersonInput { + name: String + email: String + password: String +} + +type Mutation { + createInitialPerson( + data: CreateInitialPersonInput! + ): PersonAuthenticationWithPasswordSuccess! + authenticatePersonWithPassword( + email: String! + password: String! + ): PersonAuthenticationWithPasswordResult! + createTask(data: TaskCreateInput!): Task + createTasks(data: [TaskCreateInput!]!): [Task] + updateTask(where: TaskWhereUniqueInput!, data: TaskUpdateInput!): Task + updateTasks(data: [TaskUpdateArgs!]!): [Task] + deleteTask(where: TaskWhereUniqueInput!): Task + deleteTasks(where: [TaskWhereUniqueInput!]!): [Task] + createPerson(data: PersonCreateInput!): Person + createPeople(data: [PersonCreateInput!]!): [Person] + updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person + updatePeople(data: [PersonUpdateArgs!]!): [Person] + deletePerson(where: PersonWhereUniqueInput!): Person + deletePeople(where: [PersonWhereUniqueInput!]!): [Person] + endSession: Boolean! +} + +union AuthenticatedItem = Person + +union PersonAuthenticationWithPasswordResult = + PersonAuthenticationWithPasswordSuccess + | PersonAuthenticationWithPasswordFailure + +type PersonAuthenticationWithPasswordSuccess { + sessionToken: String! + item: Person! +} + +type PersonAuthenticationWithPasswordFailure { + code: PasswordAuthErrorCode! + message: String! +} + +enum PasswordAuthErrorCode { + FAILURE + IDENTITY_NOT_FOUND + SECRET_NOT_SET + MULTIPLE_IDENTITY_MATCHES + SECRET_MISMATCH +} + type Task { id: ID! label: String @@ -225,60 +278,8 @@ scalar JSON url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" ) -type Mutation { - createTask(data: TaskCreateInput!): Task - createTasks(data: [TaskCreateInput!]!): [Task] - updateTask(where: TaskWhereUniqueInput!, data: TaskUpdateInput!): Task - updateTasks(data: [TaskUpdateArgs!]!): [Task] - deleteTask(where: TaskWhereUniqueInput!): Task - deleteTasks(where: [TaskWhereUniqueInput!]!): [Task] - createPerson(data: PersonCreateInput!): Person - createPeople(data: [PersonCreateInput!]!): [Person] - updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person - updatePeople(data: [PersonUpdateArgs!]!): [Person] - deletePerson(where: PersonWhereUniqueInput!): Person - deletePeople(where: [PersonWhereUniqueInput!]!): [Person] - authenticatePersonWithPassword( - email: String! - password: String! - ): PersonAuthenticationWithPasswordResult! - createInitialPerson( - data: CreateInitialPersonInput! - ): PersonAuthenticationWithPasswordSuccess! - endSession: Boolean! -} - -union AuthenticatedItem = Person - -union PersonAuthenticationWithPasswordResult = - PersonAuthenticationWithPasswordSuccess - | PersonAuthenticationWithPasswordFailure - -type PersonAuthenticationWithPasswordSuccess { - sessionToken: String! - item: Person! -} - -type PersonAuthenticationWithPasswordFailure { - code: PasswordAuthErrorCode! - message: String! -} - -enum PasswordAuthErrorCode { - FAILURE - IDENTITY_NOT_FOUND - SECRET_NOT_SET - MULTIPLE_IDENTITY_MATCHES - SECRET_MISMATCH -} - -input CreateInitialPersonInput { - name: String - email: String - password: String -} - type Query { + authenticatedItem: AuthenticatedItem tasks( where: TaskWhereInput! = {} orderBy: [TaskOrderByInput!]! = [] @@ -295,7 +296,6 @@ type Query { ): [Person!] person(where: PersonWhereUniqueInput!): Person peopleCount(where: PersonWhereInput! = {}): Int - authenticatedItem: AuthenticatedItem keystone: KeystoneMeta! } diff --git a/packages/auth/package.json b/packages/auth/package.json index ada36b67256..4c48673aca7 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@babel/runtime": "^7.14.8", - "@graphql-tools/merge": "^7.0.0", + "@graphql-tools/schema": "^8.1.0", "@keystone-next/admin-ui-utils": "^5.0.5", "@keystone-next/fields": "^13.0.0", "@keystone-next/types": "^23.0.0", diff --git a/packages/auth/src/schema.ts b/packages/auth/src/schema.ts index bc78ec3fd19..64cbef1e917 100644 --- a/packages/auth/src/schema.ts +++ b/packages/auth/src/schema.ts @@ -1,4 +1,4 @@ -import { mergeSchemas } from '@graphql-tools/merge'; +import { mergeSchemas } from '@graphql-tools/schema'; import { ExtendGraphqlSchema } from '@keystone-next/types'; import { diff --git a/packages/keystone/package.json b/packages/keystone/package.json index 0cdfb4b7ef2..b91251d99c7 100644 --- a/packages/keystone/package.json +++ b/packages/keystone/package.json @@ -27,7 +27,7 @@ "@babel/plugin-transform-modules-commonjs": "^7.15.0", "@babel/runtime": "^7.14.8", "@emotion/hash": "^0.8.0", - "@graphql-tools/merge": "^7.0.0", + "@graphql-tools/schema": "^8.1.0", "@hapi/iron": "^6.0.0", "@keystone-next/admin-ui-utils": "^5.0.5", "@keystone-next/fields": "^13.0.0", diff --git a/packages/keystone/src/schema/schema.ts b/packages/keystone/src/schema/schema.ts index c3694e83b19..1c84166a776 100644 --- a/packages/keystone/src/schema/schema.ts +++ b/packages/keystone/src/schema/schema.ts @@ -1,5 +1,5 @@ import type { GraphQLSchema } from 'graphql'; -import { mergeSchemas } from '@graphql-tools/merge'; +import { mergeSchemas } from '@graphql-tools/schema'; import type { BaseFields, diff --git a/yarn.lock b/yarn.lock index 18cb4af5620..73ee86bbee0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1510,29 +1510,28 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@graphql-tools/merge@7.0.0", "@graphql-tools/merge@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-7.0.0.tgz#af3380f5dc4536870397a3bac5afd0cd53e11add" - integrity sha512-u7TTwKQ7cybAkn6snYPRg3um/C2u690wlD8TgHITAmGQDAExN/yipSSBgu4rXWopsPLsY0G30mJ8tOWToZVE1w== +"@graphql-tools/merge@8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-8.0.0.tgz#0d364a11172c6cfa2928a8f46a8984ac7cca0fe1" + integrity sha512-Hdhp3qwDeRwPGUVUkmRwTg5KX/bp1MNkplhI6szgQHeDPaC2l9a1iS6LznVP6xQjsyb8oRPqlVPKfiXemodwFw== dependencies: - "@graphql-tools/schema" "^8.0.3" - "@graphql-tools/utils" "8.0.2" + "@graphql-tools/utils" "8.1.0" tslib "~2.3.0" -"@graphql-tools/schema@^8.0.3": - version "8.0.3" - resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-8.0.3.tgz#504a6b279be52a278b9c8af90b710c9dcc9ff732" - integrity sha512-ufJH7r/RcetVPd3kKCZ16/JTRkOX8aB1yGbYnUjqWEIdYEZc3Fpg7AVlcliu2JlvwR+WSNlgWn2QK76QCsFFdA== +"@graphql-tools/schema@^8.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-8.1.0.tgz#08a96c23bc8cb63e2f9fa1ea6c052a486d2c92e7" + integrity sha512-k6M877jFTKjlRU2f2YYjWx+FKXlhuQlCQQ8IdG5API4UL1qk57zYoNnYlT+CJfWxEfcMvEd6AlJ8wvmapzr53A== dependencies: - "@graphql-tools/merge" "7.0.0" - "@graphql-tools/utils" "8.0.2" + "@graphql-tools/merge" "8.0.0" + "@graphql-tools/utils" "8.1.0" tslib "~2.3.0" value-or-promise "1.0.10" -"@graphql-tools/utils@8.0.2": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-8.0.2.tgz#795a8383cdfdc89855707d62491c576f439f3c51" - integrity sha512-gzkavMOgbhnwkHJYg32Adv6f+LxjbQmmbdD5Hty0+CWxvaiuJq+nU6tzb/7VSU4cwhbNLx/lGu2jbCPEW1McZQ== +"@graphql-tools/utils@8.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-8.1.0.tgz#ea64fefa5c3bcb3dec06be765c128c1bf0cc829f" + integrity sha512-V5a7xAxZ6DHzrYYticmsLgWim+vGnC6ztbiOXrO5cGtOOk5NSK657SZXsyVOR7hNvdWiHSW0dlBZb6zkkfOnHA== dependencies: tslib "~2.3.0"