Skip to content

Commit

Permalink
refact: order graph schema
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Sep 17, 2024
1 parent b995736 commit 9ab100d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
41 changes: 41 additions & 0 deletions app/GraphQL/Souk/Mutations/Orders/DraftOrderManagementMutation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Souk\Mutations\Orders;

use Kanvas\Apps\Models\Apps;
use Kanvas\Guild\Customers\Enums\ContactTypeEnum;
use Kanvas\Inventory\Variants\Models\Variants;
use Kanvas\Social\Interactions\Actions\CreateInteraction;
use Kanvas\Social\Interactions\Actions\CreateUserInteractionAction;
use Kanvas\Social\Interactions\DataTransferObject\Interaction;
use Kanvas\Social\Interactions\DataTransferObject\UserInteraction;
use Kanvas\Souk\Orders\DataTransferObject\DirectOrder;
use Kanvas\Souk\Payments\DataTransferObject\CreditCard;
use Kanvas\Souk\Payments\Providers\AuthorizeNetPaymentProcessor;

class DraftOrderManagementMutation
{
public function create(mixed $root, array $request): array
{
$user = auth()->user();

print_R($request);
$customer = $request['input']['customer'];
$customer['contacts'] = [
[
'contact' => $request['input']['email'],
'contacts_types_id' => ContactTypeEnum::EMAIL->value,
'weight' => 0
]
];

print_r($customer); die();


return [];
}


}
28 changes: 21 additions & 7 deletions graphql/schemas/Souk/order.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ type OrderItem {
updated_at: String
}

input CreditCard {
input CreditCardInput {
name: String!
number: String!
exp_month: Int!
exp_year: Int!
cvv: Int!
}

input CreditCardBilling {
input CreditCardBillingInput {
address: String!
address2: String
city: String!
Expand All @@ -78,31 +78,41 @@ input CreditCardBilling {

input CartOrderInput {
cartId: ID!
email: String!
customer: PeopleInput
payment: CreditCard!
billing: CreditCardBilling
billing: CreditCardBillingInput
address: AddressInput
note: String
}

input OrderInput {
customer: PeopleInput!
billing: CreditCardBilling
billing: CreditCardBillingInput
address: AddressInput!
}

input DraftOrderInput {
email: String!
customer: PeopleInput!
billing: CreditCardBilling
billing: CreditCardBillingInput
address: AddressInput
items: [OrderLineItemInput!]!
note: String
metadata: Mixed
}

input OrderLineItemInput {
variant_id: ID!
quantity: Int!
}

input PaymentInput {
orderId: ID!
paymentMethod: String!
creditCard: CreditCardInput
billing: CreditCardBillingInput
}

extend type Mutation @guard {
# @deprecated(reason: "Use createOrderFromCart instead")
createOrder(input: OrderInput!): Mixed!
Expand All @@ -111,12 +121,16 @@ extend type Mutation @guard {
)
createDraftOrder(input: DraftOrderInput!): Mixed!
@field(
resolver: "App\\GraphQL\\Souk\\Mutations\\Orders\\OrderManagementMutation@create"
resolver: "App\\GraphQL\\Souk\\Mutations\\Orders\\DraftOrderManagementMutation@create"
)
createOrderFromCart(input: CartOrderInput!): Mixed!
@field(
resolver: "App\\GraphQL\\Souk\\Mutations\\Orders\\OrderManagementMutation@create"
)
#assignPaymentToOrder(input: PaymentInput!): Mixed!
# @field(
# resolver: "App\\GraphQL\\Souk\\Mutations\\Orders\\OrderManagementMutation@assignPaymentToOrder"
# )
}

extend type Query @guard {
Expand Down

0 comments on commit 9ab100d

Please sign in to comment.