Skip to content

Commit

Permalink
GraphQL Type Validations Removed
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank-webkul committed Sep 24, 2024
1 parent 2afda42 commit f145220
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 81 deletions.
6 changes: 3 additions & 3 deletions Postman_APIs/Collections/GraphQL-API.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -6563,7 +6563,7 @@
"mode": "graphql",
"graphql": {
"query": "mutation createUser ($input : CreateUserInput!){\n createUser(input: $input) {\n success\n message\n user {\n id\n name\n email\n password\n apiToken\n status\n roleId\n image\n rememberToken\n createdAt\n updatedAt\n role {\n id\n name\n description\n permissionType\n permissions\n createdAt\n updatedAt\n }\n }\n }\n}",
"variables": "{\n \"input\": {\n \"name\": \"Test Eva\",\n \"email\": \"tests_aevaaa@example.com\",\n \t\"password\": \"admin123\",\n \t\"passwordConfirmation\": \"admin123\",\n \t\"roleId\": 1,\n \t\"status\": true,\n \"image\": \"https://cdn.pixabay.com/photo/2017/05/23/10/53/t-shirt-design-2336850_960_720.jpg\"\n }\n}"
"variables": "{\n \"input\": {\n \"name\": \"Test Eva\",\n \"email\": \"eva@example.com\",\n \t\"password\": \"admin123\",\n \t\"passwordConfirmation\": \"admin123\",\n \t\"roleId\": 1,\n \t\"status\": true,\n \"image\": \"https://cdn.pixabay.com/photo/2017/05/23/10/53/t-shirt-design-2336850_960_720.jpg\"\n }\n}"
}
},
"url": {
Expand Down Expand Up @@ -6594,7 +6594,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "mutation updateUser {\n updateUser(id: 2, input: {\n name: \"Admin2\"\n email: \"[email protected]\"\n password: \"admin123\"\n passwordConfirmation: \"admin123\"\n roleId: 1\n status: true\n image: \"https://cdn.pixabay.com/photo/2017/05/23/10/53/t-shirt-design-2336850_960_720.jpg\"\n }) {\n success\n message\n user {\n id\n name\n email\n password\n apiToken\n status\n roleId\n image\n rememberToken\n createdAt\n updatedAt\n role {\n id\n name\n description\n permissionType\n permissions\n createdAt\n updatedAt\n }\n }\n }\n}\n",
"query": "mutation updateUser {\n updateUser(id: 5, input: {\n name: \"Admin2\"\n email: \"[email protected]\"\n password: \"admin123\"\n passwordConfirmation: \"admin123\"\n roleId: 1\n status: true\n image: \"https://cdn.pixabay.com/photo/2017/05/23/10/53/t-shirt-design-2336850_960_720.jpg\"\n }) {\n success\n message\n user {\n id\n name\n email\n password\n apiToken\n status\n roleId\n image\n rememberToken\n createdAt\n updatedAt\n role {\n id\n name\n description\n permissionType\n permissions\n createdAt\n updatedAt\n }\n }\n }\n}\n",
"variables": ""
}
},
Expand Down Expand Up @@ -7912,7 +7912,7 @@
"mode": "graphql",
"graphql": {
"query": "mutation customerSignUp (\n $input: SignUpInput!\n) {\n customerSignUp(\n input: $input\n ) {\n success\n message\n accessToken\n tokenType\n expiresIn\n customer {\n id\n firstName\n lastName\n name\n gender\n dateOfBirth\n email\n phone\n image\n imageUrl\n status\n password\n apiToken\n customerGroupId\n subscribedToNewsLetter\n isVerified\n isSuspended\n token\n rememberToken\n createdAt\n updatedAt\n }\n }\n}",
"variables": "{\n \"input\": {\n \"firstName\": \"Customer\",\n \"lastName\": \"1\",\n \"email\": \"customer1@example.com\",\n \t\"password\": \"admin123\",\n \t\"passwordConfirmation\": \"admin123\",\n \"subscribedToNewsLetter\": true \n }\n}"
"variables": "{\n \"input\": {\n \"firstName\": \"Customer\",\n \"lastName\": \"1\",\n \"email\": \"customer@example.com\",\n \t\"password\": \"admin123\",\n \t\"passwordConfirmation\": \"admin123\",\n \"subscribedToNewsLetter\": true \n }\n}"
}
},
"url": {
Expand Down
9 changes: 4 additions & 5 deletions src/Mutations/Shop/Customer/RegistrationMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public function __construct(
public function signUp(mixed $rootValue, array $args, GraphQLContext $context)
{
bagisto_graphql()->validate($args, [
'email' => 'email|required|unique:customers,email',
'first_name' => 'string|required',
'last_name' => 'string|required',
'password' => 'min:6|required',
'password_confirmation' => 'required|required_with:password|same:password',
'email' => 'email|required|unique:customers,email',
'first_name' => 'string|required',
'last_name' => 'string|required',
'password' => 'min:6|required|confirmed',
]);

$this->create($args);
Expand Down
10 changes: 5 additions & 5 deletions src/graphql/admin/customer/customers/customer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ input FilterCustomerInput {
}

input CreateCustomerInput {
firstName: String! @rename(attribute: "first_name") @rules(apply: ["required"])
lastName: String! @rename(attribute: "last_name") @rules(apply: ["required"])
gender: Gender! @rules(apply: ["required"])
email: String! @rules(apply: ["required","email"])
firstName: String! @rename(attribute: "first_name")
lastName: String! @rename(attribute: "last_name")
gender: Gender!
email: String!
dateOfBirth: String @rename(attribute: "date_of_birth")
customerGroupId: Int! @rename(attribute: "customer_group_id")
phone: String
Expand All @@ -58,7 +58,7 @@ input CreateCustomerInput {
}

input CreateCustomerNoteInput {
note: String! @rules(apply: ["required"])
note: String!
customerNotified: Boolean @rename(attribute: "customer_notified")
}

Expand Down
20 changes: 10 additions & 10 deletions src/graphql/admin/customer/customers/customer_address.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ input FilterCustomerAddressInput {
}

input CreateCustomerAddressInput {
customerId: Int! @rename(attribute: "customer_id") @rules(apply: ["required"])
customerId: Int! @rename(attribute: "customer_id")
companyName: String @rename(attribute: "company_name")
vatId: String @rename(attribute: "vat_id")
firstName: String! @rename(attribute: "first_name") @rules(apply: ["required"])
lastName: String! @rename(attribute: "last_name") @rules(apply: ["required"])
address: String! @rules(apply: ["required"])
city: String! @rules(apply: ["required"])
postcode: String! @rules(apply: ["integer","required"])
country: String! @rules(apply: ["required"])
state: String! @rules(apply: ["required"])
phone: String! @rules(apply: ["integer"])
email: String! @rules(apply: ["required"])
firstName: String! @rename(attribute: "first_name")
lastName: String! @rename(attribute: "last_name")
address: String!
city: String!
postcode: String!
country: String!
state: String!
phone: String!
email: String!
defaultAddress: Boolean @rename(attribute: "default_address")
}
4 changes: 2 additions & 2 deletions src/graphql/admin/customer/groups/customer_group.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ input FilterCustomerGroupInput {
}

input CreateCustomerGroupInput {
name: String! @rules(apply: ["required"])
code: String! @rules(apply: ["required"])
name: String!
code: String!
}

type CustomerGroupResponse {
Expand Down
22 changes: 11 additions & 11 deletions src/graphql/admin/setting/channel.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ input FilterChannelInput {
}

input CreateChannelInput {
code: String! @rules(apply: ["required"])
name: String! @rules(apply: ["required"])
code: String!
name: String!
description: String
theme: String
hostname: String
defaultLocaleId: Int! @rename(attribute: "default_locale_id") @rules(apply: ["required"])
baseCurrencyId: Int! @rename(attribute: "base_currency_id") @rules(apply: ["required"])
rootCategoryId: Int! @rename(attribute: "root_category_id") @rules(apply: ["required"])
locales: [String!]! @rules(apply: ["required"])
currencies: [String!]! @rules(apply: ["required"])
inventorySources: [String!] @rename(attribute: "inventory_sources") @rules(apply: ["required"])
defaultLocaleId: Int! @rename(attribute: "default_locale_id")
baseCurrencyId: Int! @rename(attribute: "base_currency_id")
rootCategoryId: Int! @rename(attribute: "root_category_id")
locales: [String!]!
currencies: [String!]!
inventorySources: [String!] @rename(attribute: "inventory_sources")
logo: String
favicon:String
seoTitle: String! @rename(attribute: "seo_title") @rules(apply: ["required"])
seoDescription: String! @rename(attribute: "seo_description") @rules(apply: ["required"])
seoKeywords: String! @rename(attribute: "seo_keywords") @rules(apply: ["required"])
seoTitle: String! @rename(attribute: "seo_title")
seoDescription: String! @rename(attribute: "seo_description")
seoKeywords: String! @rename(attribute: "seo_keywords")
maintenanceModeText: String @rename(attribute: "maintenance_mode_text")
allowedIps: String @rename(attribute: "allowed_ips")
isMaintenanceOn: Boolean @rename(attribute: "is_maintenance_on")
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/admin/setting/exchange_rate.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ input FilterExchangeRateInput {
id: Int
targetCurrency: Int @rename(attribute: "target_currency")
currency: String
rate: Float @rules(apply: ["numeric"])
rate: Float
}

input CreateExchangeRateInput {
targetCurrency: Int! @rename(attribute: "target_currency") @rules(apply: ["required"])
rate: Float! @rules(apply: ["numeric", "required"])
targetCurrency: Int! @rename(attribute: "target_currency")
rate: Float!
}

type ExchangeRateResponse {
Expand Down
20 changes: 10 additions & 10 deletions src/graphql/admin/setting/inventory_source.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ input FilterInventorySourceInput {
}

input createInventorySourceInput {
code: String! @rules(apply: ["required"])
name: String! @rules(apply: ["required"])
code: String!
name: String!
description: String
contactName: String! @rename(attribute: "contact_name") @rules(apply: ["required"])
contactEmail: String! @rename(attribute: "contact_email") @rules(apply: ["required"])
contactNumber: String! @rename(attribute: "contact_number") @rules(apply: ["required"])
contactName: String! @rename(attribute: "contact_name")
contactEmail: String! @rename(attribute: "contact_email")
contactNumber: String! @rename(attribute: "contact_number")
contactFax: String @rename(attribute: "contact_fax")
country: String! @rules(apply: ["required"])
state: String! @rules(apply: ["required"])
city: String! @rules(apply: ["required"])
street: String! @rules(apply: ["required"])
postcode: String! @rules(apply: ["required"])
country: String!
state: String!
city: String!
street: String!
postcode: String!
priority: Int
latitude: String
longitude: String
Expand Down
8 changes: 4 additions & 4 deletions src/graphql/admin/setting/tax_category.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ input FilterTaxCategoryInput {
}

input createTaxCategoryInput {
code: String! @rules(apply: ["required"])
name: String! @rules(apply: ["required"])
description: String! @rules(apply: ["required"])
taxrates: [Int!]! @rules(apply: ["required"])
code: String!
name: String!
description: String!
taxrates: [Int!]!
}

type TaxCategoryResponse {
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/admin/setting/tax_rate.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ input FilterTaxRateInput {
}

input createTaxRateInput {
identifier: String! @rules(apply: ["required"])
identifier: String!
isZip: String @rename(attribute: "is_zip")
zipCode: String @rename(attribute: "zip_code")
zipFrom: String @rename(attribute: "zip_from")
zipTo: String @rename(attribute: "zip_to")
state: String!
country: String! @rules(apply: ["required"])
taxRate: Float! @rename(attribute: "tax_rate") @rules(apply: ["required"])
country: String!
taxRate: Float! @rename(attribute: "tax_rate")
}

type TaxRateResponse {
Expand Down
14 changes: 7 additions & 7 deletions src/graphql/admin/setting/theme.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ input FilterThemesInput {
}

input CreateThemeInput {
name: String! @rules(apply: ["required"])
sortOrder: Int! @rename(attribute: "sort_order") @rules(apply: ["required"])
type: ThemeType! @rules(apply: ["required"])
channelId: ID! @rename(attribute: "channel_id") @rules(apply: ["required"])
name: String!
sortOrder: Int! @rename(attribute: "sort_order")
type: ThemeType!
channelId: ID! @rename(attribute: "channel_id")
themeCode: String @rename(attribute: "theme_code")
}

Expand All @@ -47,9 +47,9 @@ enum ThemeType {
}

input UpdateThemeInput {
name: String! @rules(apply: ["required"])
sortOrder: Int! @rename(attribute: "sort_order") @rules(apply: ["required"])
channelId: ID! @rename(attribute: "channel_id") @rules(apply: ["required"])
name: String!
sortOrder: Int! @rename(attribute: "sort_order")
channelId: ID! @rename(attribute: "channel_id")
status: Boolean
themeCode: String @rename(attribute: "theme_code")
options: OptionInputTheme!
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/shop/cart/cart.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ input UpdateItemToCartInput {
}

input UpdateItemsQty {
cartItemId: ID! @rename(attribute: "cart_item_id") @rules(apply: ["required"])
quantity: Int! @rules(apply: ["min:1","required"])
cartItemId: ID! @rename(attribute: "cart_item_id")
quantity: Int!
}

type CartItemResponse {
Expand Down
12 changes: 6 additions & 6 deletions src/graphql/shop/customer/account.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ extend type Mutation {
): CustomerResponse @guard(with: ["api"]) @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\AccountMutation@update")

deleteAccount(
password: String! @rules(apply: ["required"])
password: String!
): StatusResponse @guard(with: ["api"]) @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\AccountMutation@delete")
}

input UpdateAccountInput {
firstName: String! @rename(attribute: "first_name") @rules(apply: ["required"])
lastName: String! @rename(attribute: "last_name") @rules(apply: ["required"])
email: String! @rules(apply: ["email"])
phone: String! @rules(apply: ["required"])
gender: Gender! @rules(apply: ["required"])
firstName: String! @rename(attribute: "first_name")
lastName: String! @rename(attribute: "last_name")
email: String!
phone: String!
gender: Gender!
dateOfBirth: String @rename(attribute: "date_of_birth")
currentPassword: String @rename(attribute: "current_password")
newPassword: String @rename(attribute: "new_password")
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/shop/customer/forgot_password.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Shop\Customer\ForgotPassword Related APIs
extend type Mutation {
forgotPassword(
email: String! @rules(apply: ["email"])
email: String!
): StatusResponse @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\ForgotPasswordMutation@forgot")
}
10 changes: 5 additions & 5 deletions src/graphql/shop/customer/registration.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ input SignUpInput {
firstName: String! @rename(attribute: "first_name")
lastName: String! @rename(attribute: "last_name")
email: String!
password: String! @rules(apply: ["min:6"])
passwordConfirmation: String! @rules(apply: ["min:6"]) @rename(attribute: "password_confirmation")
password: String!
passwordConfirmation: String! @rename(attribute: "password_confirmation")
subscribedToNewsLetter: Boolean @rename(attribute: "subscribed_to_news_letter")
}

input SocialSignInInput {
firstName: String @rename(attribute: "first_name") @rules(apply: ["required"])
lastName: String @rename(attribute: "last_name") @rules(apply: ["required"])
email: String! @rules(apply: ["email"])
firstName: String @rename(attribute: "first_name")
lastName: String @rename(attribute: "last_name")
email: String!
phone: String
signupType: SocialSignInType! @rename(attribute: "signup_type")
password: String
Expand Down
8 changes: 4 additions & 4 deletions src/graphql/shop/customer/wishlist.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ extend type Query @guard(with: ["api"]) {

extend type Mutation @guard(with: ["api"]) {
addToWishlist(
productId: ID! @rename(attribute: "product_id") @rules(apply: ["required"])
productId: ID! @rename(attribute: "product_id")
): WishlistResponse @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\WishlistMutation@store")

removeFromWishlist(
productId: ID! @rename(attribute: "product_id") @rules(apply: ["required"])
productId: ID! @rename(attribute: "product_id")
): WishlistResponse @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\WishlistMutation@delete")

moveToCart(
id: ID @eq @rules(apply: ["min:1", "required"])
quantity: Int! @rules(apply: ["min:1", "required"])
id: ID!
quantity: Int!
): WishlistResponse @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\WishlistMutation@move")

removeAllWishlists: StatusResponse @field(resolver: "Webkul\\GraphQLAPI\\Mutations\\Shop\\Customer\\WishlistMutation@deleteAll")
Expand Down

0 comments on commit f145220

Please sign in to comment.