Fix delete vendor does not update the UI
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -27,7 +27,12 @@ import { VendorListPage_vendors$key } from "./__generated__/VendorListPage_vendo
|
|||||||
const ITEMS_PER_PAGE = 25;
|
const ITEMS_PER_PAGE = 25;
|
||||||
|
|
||||||
const vendorListPageQuery = graphql`
|
const vendorListPageQuery = graphql`
|
||||||
query VendorListPageQuery($first: Int, $after: CursorKey, $last: Int, $before: CursorKey) {
|
query VendorListPageQuery(
|
||||||
|
$first: Int
|
||||||
|
$after: CursorKey
|
||||||
|
$last: Int
|
||||||
|
$before: CursorKey
|
||||||
|
) {
|
||||||
currentOrganization: node(id: "AZSfP_xAcAC5IAAAAAAltA") {
|
currentOrganization: node(id: "AZSfP_xAcAC5IAAAAAAltA") {
|
||||||
id
|
id
|
||||||
... on Organization {
|
... on Organization {
|
||||||
@@ -41,12 +46,8 @@ const vendorListFragment = graphql`
|
|||||||
fragment VendorListPage_vendors on Organization
|
fragment VendorListPage_vendors on Organization
|
||||||
@refetchable(queryName: "VendorListPagePaginationQuery") {
|
@refetchable(queryName: "VendorListPagePaginationQuery") {
|
||||||
id
|
id
|
||||||
vendors(
|
vendors(first: $first, after: $after, last: $last, before: $before)
|
||||||
first: $first
|
@connection(key: "VendorListPage_vendors") {
|
||||||
after: $after
|
|
||||||
last: $last
|
|
||||||
before: $before
|
|
||||||
) @connection(key: "VendorListPage_vendors") {
|
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
id
|
id
|
||||||
@@ -66,7 +67,10 @@ const vendorListFragment = graphql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const createVendorMutation = graphql`
|
const createVendorMutation = graphql`
|
||||||
mutation VendorListPageCreateVendorMutation($input: CreateVendorInput!, $connections: [ID!]!) {
|
mutation VendorListPageCreateVendorMutation(
|
||||||
|
$input: CreateVendorInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
createVendor(input: $input) {
|
createVendor(input: $input) {
|
||||||
vendorEdge @prependEdge(connections: $connections) {
|
vendorEdge @prependEdge(connections: $connections) {
|
||||||
node {
|
node {
|
||||||
@@ -81,8 +85,13 @@ const createVendorMutation = graphql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const deleteVendorMutation = graphql`
|
const deleteVendorMutation = graphql`
|
||||||
mutation VendorListPageDeleteVendorMutation($input: DeleteVendorInput!) {
|
mutation VendorListPageDeleteVendorMutation(
|
||||||
deleteVendor(input: $input)
|
$input: DeleteVendorInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
|
deleteVendor(input: $input) {
|
||||||
|
deletedVendorId @deleteEdge(connections: $connections)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -162,13 +171,18 @@ function VendorListContent({
|
|||||||
}: {
|
}: {
|
||||||
queryRef: PreloadedQuery<VendorListPageQueryType>;
|
queryRef: PreloadedQuery<VendorListPageQueryType>;
|
||||||
}) {
|
}) {
|
||||||
const data = usePreloadedQuery<VendorListPageQueryType>(vendorListPageQuery, queryRef);
|
const data = usePreloadedQuery<VendorListPageQueryType>(
|
||||||
|
vendorListPageQuery,
|
||||||
|
queryRef,
|
||||||
|
);
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
const [filteredVendors, setFilteredVendors] = useState<Array<any>>([]);
|
const [filteredVendors, setFilteredVendors] = useState<Array<any>>([]);
|
||||||
const [createVendor] = useMutation<VendorListPageCreateVendorMutation>(createVendorMutation);
|
const [createVendor] =
|
||||||
const [deleteVendor] = useMutation<VendorListPageDeleteVendorMutation>(deleteVendorMutation);
|
useMutation<VendorListPageCreateVendorMutation>(createVendorMutation);
|
||||||
|
const [deleteVendor] =
|
||||||
|
useMutation<VendorListPageDeleteVendorMutation>(deleteVendorMutation);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: vendorsConnection,
|
data: vendorsConnection,
|
||||||
@@ -178,9 +192,13 @@ function VendorListContent({
|
|||||||
hasPrevious,
|
hasPrevious,
|
||||||
isLoadingNext,
|
isLoadingNext,
|
||||||
isLoadingPrevious,
|
isLoadingPrevious,
|
||||||
} = usePaginationFragment<VendorListPagePaginationQuery, VendorListPage_vendors$key>(vendorListFragment, data.currentOrganization);
|
} = usePaginationFragment<
|
||||||
|
VendorListPagePaginationQuery,
|
||||||
|
VendorListPage_vendors$key
|
||||||
|
>(vendorListFragment, data.currentOrganization);
|
||||||
|
|
||||||
const vendors = vendorsConnection.vendors.edges.map((edge) => edge.node) ?? [];
|
const vendors =
|
||||||
|
vendorsConnection.vendors.edges.map((edge) => edge.node) ?? [];
|
||||||
const pageInfo = vendorsConnection.vendors.pageInfo;
|
const pageInfo = vendorsConnection.vendors.pageInfo;
|
||||||
|
|
||||||
const fuse = new Fuse(vendorsList, {
|
const fuse = new Fuse(vendorsList, {
|
||||||
@@ -239,7 +257,12 @@ function VendorListContent({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
createVendor({
|
createVendor({
|
||||||
variables: {
|
variables: {
|
||||||
connections: [ConnectionHandler.getConnectionID(data.currentOrganization.id, "VendorListPageQuery_vendors")],
|
connections: [
|
||||||
|
ConnectionHandler.getConnectionID(
|
||||||
|
data.currentOrganization.id,
|
||||||
|
"VendorListPageQuery_vendors",
|
||||||
|
),
|
||||||
|
],
|
||||||
input: {
|
input: {
|
||||||
organizationId: data.currentOrganization.id,
|
organizationId: data.currentOrganization.id,
|
||||||
name: vendor.name,
|
name: vendor.name,
|
||||||
@@ -254,7 +277,8 @@ function VendorListContent({
|
|||||||
setFilteredVendors([]);
|
setFilteredVendors([]);
|
||||||
toast({
|
toast({
|
||||||
title: "Vendor added",
|
title: "Vendor added",
|
||||||
description: "The vendor has been added successfully",
|
description:
|
||||||
|
"The vendor has been added successfully",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -343,6 +367,12 @@ function VendorListContent({
|
|||||||
) {
|
) {
|
||||||
deleteVendor({
|
deleteVendor({
|
||||||
variables: {
|
variables: {
|
||||||
|
connections: [
|
||||||
|
ConnectionHandler.getConnectionID(
|
||||||
|
data.currentOrganization.id,
|
||||||
|
"VendorListPage_vendors",
|
||||||
|
),
|
||||||
|
],
|
||||||
input: {
|
input: {
|
||||||
vendorId: vendor.id,
|
vendorId: vendor.id,
|
||||||
},
|
},
|
||||||
@@ -350,7 +380,8 @@ function VendorListContent({
|
|||||||
onCompleted() {
|
onCompleted() {
|
||||||
toast({
|
toast({
|
||||||
title: "Vendor deleted",
|
title: "Vendor deleted",
|
||||||
description: "The vendor has been deleted successfully",
|
description:
|
||||||
|
"The vendor has been deleted successfully",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<b97adcd0ae4816dc772fcbf3b3c6b3d7>>
|
* @generated SignedSource<<ff037e64f503f247a68922f86248bb10>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -13,10 +13,13 @@ export type DeleteVendorInput = {
|
|||||||
vendorId: string;
|
vendorId: string;
|
||||||
};
|
};
|
||||||
export type VendorListPageDeleteVendorMutation$variables = {
|
export type VendorListPageDeleteVendorMutation$variables = {
|
||||||
|
connections: ReadonlyArray<string>;
|
||||||
input: DeleteVendorInput;
|
input: DeleteVendorInput;
|
||||||
};
|
};
|
||||||
export type VendorListPageDeleteVendorMutation$data = {
|
export type VendorListPageDeleteVendorMutation$data = {
|
||||||
readonly deleteVendor: any;
|
readonly deleteVendor: {
|
||||||
|
readonly deletedVendorId: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
export type VendorListPageDeleteVendorMutation = {
|
export type VendorListPageDeleteVendorMutation = {
|
||||||
response: VendorListPageDeleteVendorMutation$data;
|
response: VendorListPageDeleteVendorMutation$data;
|
||||||
@@ -24,56 +27,106 @@ export type VendorListPageDeleteVendorMutation = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const node: ConcreteRequest = (function(){
|
const node: ConcreteRequest = (function(){
|
||||||
var v0 = [
|
var v0 = {
|
||||||
{
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "connections"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
"defaultValue": null,
|
"defaultValue": null,
|
||||||
"kind": "LocalArgument",
|
"kind": "LocalArgument",
|
||||||
"name": "input"
|
"name": "input"
|
||||||
}
|
},
|
||||||
],
|
v2 = [
|
||||||
v1 = [
|
|
||||||
{
|
|
||||||
"alias": null,
|
|
||||||
"args": [
|
|
||||||
{
|
{
|
||||||
"kind": "Variable",
|
"kind": "Variable",
|
||||||
"name": "input",
|
"name": "input",
|
||||||
"variableName": "input"
|
"variableName": "input"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
"kind": "ScalarField",
|
"kind": "ScalarField",
|
||||||
"name": "deleteVendor",
|
"name": "deletedVendorId",
|
||||||
"storageKey": null
|
"storageKey": null
|
||||||
}
|
};
|
||||||
];
|
|
||||||
return {
|
return {
|
||||||
"fragment": {
|
"fragment": {
|
||||||
"argumentDefinitions": (v0/*: any*/),
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
"kind": "Fragment",
|
"kind": "Fragment",
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
"name": "VendorListPageDeleteVendorMutation",
|
"name": "VendorListPageDeleteVendorMutation",
|
||||||
"selections": (v1/*: any*/),
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "DeleteVendorPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteVendor",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
"type": "Mutation",
|
"type": "Mutation",
|
||||||
"abstractKey": null
|
"abstractKey": null
|
||||||
},
|
},
|
||||||
"kind": "Request",
|
"kind": "Request",
|
||||||
"operation": {
|
"operation": {
|
||||||
"argumentDefinitions": (v0/*: any*/),
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
"kind": "Operation",
|
"kind": "Operation",
|
||||||
"name": "VendorListPageDeleteVendorMutation",
|
"name": "VendorListPageDeleteVendorMutation",
|
||||||
"selections": (v1/*: any*/)
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "DeleteVendorPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteVendor",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"filters": null,
|
||||||
|
"handle": "deleteEdge",
|
||||||
|
"key": "",
|
||||||
|
"kind": "ScalarHandle",
|
||||||
|
"name": "deletedVendorId",
|
||||||
|
"handleArgs": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "connections",
|
||||||
|
"variableName": "connections"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "6b9ec06210106cc8f8905fbfda5c60b0",
|
"cacheID": "278e42c6c988a64d4c863198f02df901",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "VendorListPageDeleteVendorMutation",
|
"name": "VendorListPageDeleteVendorMutation",
|
||||||
"operationKind": "mutation",
|
"operationKind": "mutation",
|
||||||
"text": "mutation VendorListPageDeleteVendorMutation(\n $input: DeleteVendorInput!\n) {\n deleteVendor(input: $input)\n}\n"
|
"text": "mutation VendorListPageDeleteVendorMutation(\n $input: DeleteVendorInput!\n) {\n deleteVendor(input: $input) {\n deletedVendorId\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(node as any).hash = "a435b00067d595fc8a1dec393ed1d0b6";
|
(node as any).hash = "20a320191535706246ae00aa05df991e";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ type Query {
|
|||||||
type Mutation {
|
type Mutation {
|
||||||
createVendor(input: CreateVendorInput!): CreateVendorPayload!
|
createVendor(input: CreateVendorInput!): CreateVendorPayload!
|
||||||
updateVendor(input: UpdateVendorInput!): Vendor!
|
updateVendor(input: UpdateVendorInput!): Vendor!
|
||||||
deleteVendor(input: DeleteVendorInput!): Void!
|
deleteVendor(input: DeleteVendorInput!): DeleteVendorPayload!
|
||||||
createPeople(input: CreatePeopleInput!): CreatePeoplePayload!
|
createPeople(input: CreatePeopleInput!): CreatePeoplePayload!
|
||||||
updatePeople(input: UpdatePeopleInput!): People!
|
updatePeople(input: UpdatePeopleInput!): People!
|
||||||
deletePeople(input: DeletePeopleInput!): Void!
|
deletePeople(input: DeletePeopleInput!): Void!
|
||||||
@@ -393,3 +393,8 @@ type CreatePeoplePayload {
|
|||||||
type CreateVendorPayload {
|
type CreateVendorPayload {
|
||||||
vendorEdge: VendorEdge!
|
vendorEdge: VendorEdge!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteVendorPayload {
|
||||||
|
vendorEdge: VendorEdge!
|
||||||
|
deletedVendorId: ID!
|
||||||
|
}
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ type ComplexityRoot struct {
|
|||||||
VendorEdge func(childComplexity int) int
|
VendorEdge func(childComplexity int) int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeleteVendorPayload struct {
|
||||||
|
DeletedVendorID func(childComplexity int) int
|
||||||
|
VendorEdge func(childComplexity int) int
|
||||||
|
}
|
||||||
|
|
||||||
Evidence struct {
|
Evidence struct {
|
||||||
CreatedAt func(childComplexity int) int
|
CreatedAt func(childComplexity int) int
|
||||||
FileURL func(childComplexity int) int
|
FileURL func(childComplexity int) int
|
||||||
@@ -295,7 +300,7 @@ type FrameworkResolver interface {
|
|||||||
type MutationResolver interface {
|
type MutationResolver interface {
|
||||||
CreateVendor(ctx context.Context, input types.CreateVendorInput) (*types.CreateVendorPayload, error)
|
CreateVendor(ctx context.Context, input types.CreateVendorInput) (*types.CreateVendorPayload, error)
|
||||||
UpdateVendor(ctx context.Context, input types.UpdateVendorInput) (*types.Vendor, error)
|
UpdateVendor(ctx context.Context, input types.UpdateVendorInput) (*types.Vendor, error)
|
||||||
DeleteVendor(ctx context.Context, input types.DeleteVendorInput) (string, error)
|
DeleteVendor(ctx context.Context, input types.DeleteVendorInput) (*types.DeleteVendorPayload, error)
|
||||||
CreatePeople(ctx context.Context, input types.CreatePeopleInput) (*types.CreatePeoplePayload, error)
|
CreatePeople(ctx context.Context, input types.CreatePeopleInput) (*types.CreatePeoplePayload, error)
|
||||||
UpdatePeople(ctx context.Context, input types.UpdatePeopleInput) (*types.People, error)
|
UpdatePeople(ctx context.Context, input types.UpdatePeopleInput) (*types.People, error)
|
||||||
DeletePeople(ctx context.Context, input types.DeletePeopleInput) (string, error)
|
DeletePeople(ctx context.Context, input types.DeletePeopleInput) (string, error)
|
||||||
@@ -517,6 +522,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.CreateVendorPayload.VendorEdge(childComplexity), true
|
return e.complexity.CreateVendorPayload.VendorEdge(childComplexity), true
|
||||||
|
|
||||||
|
case "DeleteVendorPayload.deletedVendorId":
|
||||||
|
if e.complexity.DeleteVendorPayload.DeletedVendorID == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.DeleteVendorPayload.DeletedVendorID(childComplexity), true
|
||||||
|
|
||||||
|
case "DeleteVendorPayload.vendorEdge":
|
||||||
|
if e.complexity.DeleteVendorPayload.VendorEdge == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.DeleteVendorPayload.VendorEdge(childComplexity), true
|
||||||
|
|
||||||
case "Evidence.createdAt":
|
case "Evidence.createdAt":
|
||||||
if e.complexity.Evidence.CreatedAt == nil {
|
if e.complexity.Evidence.CreatedAt == nil {
|
||||||
break
|
break
|
||||||
@@ -1730,7 +1749,7 @@ type Query {
|
|||||||
type Mutation {
|
type Mutation {
|
||||||
createVendor(input: CreateVendorInput!): CreateVendorPayload!
|
createVendor(input: CreateVendorInput!): CreateVendorPayload!
|
||||||
updateVendor(input: UpdateVendorInput!): Vendor!
|
updateVendor(input: UpdateVendorInput!): Vendor!
|
||||||
deleteVendor(input: DeleteVendorInput!): Void!
|
deleteVendor(input: DeleteVendorInput!): DeleteVendorPayload!
|
||||||
createPeople(input: CreatePeopleInput!): CreatePeoplePayload!
|
createPeople(input: CreatePeopleInput!): CreatePeoplePayload!
|
||||||
updatePeople(input: UpdatePeopleInput!): People!
|
updatePeople(input: UpdatePeopleInput!): People!
|
||||||
deletePeople(input: DeletePeopleInput!): Void!
|
deletePeople(input: DeletePeopleInput!): Void!
|
||||||
@@ -1806,7 +1825,13 @@ type CreatePeoplePayload {
|
|||||||
|
|
||||||
type CreateVendorPayload {
|
type CreateVendorPayload {
|
||||||
vendorEdge: VendorEdge!
|
vendorEdge: VendorEdge!
|
||||||
}`, BuiltIn: false},
|
}
|
||||||
|
|
||||||
|
type DeleteVendorPayload {
|
||||||
|
vendorEdge: VendorEdge!
|
||||||
|
deletedVendorId: ID!
|
||||||
|
}
|
||||||
|
`, BuiltIn: false},
|
||||||
}
|
}
|
||||||
var parsedSchema = gqlparser.MustLoadSchema(sources...)
|
var parsedSchema = gqlparser.MustLoadSchema(sources...)
|
||||||
|
|
||||||
@@ -3789,6 +3814,88 @@ func (ec *executionContext) fieldContext_CreateVendorPayload_vendorEdge(_ contex
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _DeleteVendorPayload_vendorEdge(ctx context.Context, field graphql.CollectedField, obj *types.DeleteVendorPayload) (ret graphql.Marshaler) {
|
||||||
|
fc, err := ec.fieldContext_DeleteVendorPayload_vendorEdge(ctx, field)
|
||||||
|
if err != nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||||
|
ctx = rctx // use context from middleware stack in children
|
||||||
|
return obj.VendorEdge, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
if resTmp == nil {
|
||||||
|
if !graphql.HasFieldError(ctx, fc) {
|
||||||
|
ec.Errorf(ctx, "must not be null")
|
||||||
|
}
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
res := resTmp.(*types.VendorEdge)
|
||||||
|
fc.Result = res
|
||||||
|
return ec.marshalNVendorEdge2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋapiᚋconsoleᚋv1ᚋtypesᚐVendorEdge(ctx, field.Selections, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) fieldContext_DeleteVendorPayload_vendorEdge(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "DeleteVendorPayload",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: false,
|
||||||
|
IsResolver: false,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
switch field.Name {
|
||||||
|
case "cursor":
|
||||||
|
return ec.fieldContext_VendorEdge_cursor(ctx, field)
|
||||||
|
case "node":
|
||||||
|
return ec.fieldContext_VendorEdge_node(ctx, field)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("no field named %q was found under type VendorEdge", field.Name)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _DeleteVendorPayload_deletedVendorId(ctx context.Context, field graphql.CollectedField, obj *types.DeleteVendorPayload) (ret graphql.Marshaler) {
|
||||||
|
fc, err := ec.fieldContext_DeleteVendorPayload_deletedVendorId(ctx, field)
|
||||||
|
if err != nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||||
|
ctx = rctx // use context from middleware stack in children
|
||||||
|
return obj.DeletedVendorID, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
if resTmp == nil {
|
||||||
|
if !graphql.HasFieldError(ctx, fc) {
|
||||||
|
ec.Errorf(ctx, "must not be null")
|
||||||
|
}
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
res := resTmp.(gid.GID)
|
||||||
|
fc.Result = res
|
||||||
|
return ec.marshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) fieldContext_DeleteVendorPayload_deletedVendorId(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "DeleteVendorPayload",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: false,
|
||||||
|
IsResolver: false,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return nil, errors.New("field of type ID does not have child fields")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Evidence_id(ctx context.Context, field graphql.CollectedField, obj *types.Evidence) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Evidence_id(ctx context.Context, field graphql.CollectedField, obj *types.Evidence) (ret graphql.Marshaler) {
|
||||||
fc, err := ec.fieldContext_Evidence_id(ctx, field)
|
fc, err := ec.fieldContext_Evidence_id(ctx, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -5253,9 +5360,9 @@ func (ec *executionContext) _Mutation_deleteVendor(ctx context.Context, field gr
|
|||||||
}
|
}
|
||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
res := resTmp.(string)
|
res := resTmp.(*types.DeleteVendorPayload)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNVoid2string(ctx, field.Selections, res)
|
return ec.marshalNDeleteVendorPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteVendorPayload(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_Mutation_deleteVendor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
func (ec *executionContext) fieldContext_Mutation_deleteVendor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
@@ -5265,7 +5372,13 @@ func (ec *executionContext) fieldContext_Mutation_deleteVendor(ctx context.Conte
|
|||||||
IsMethod: true,
|
IsMethod: true,
|
||||||
IsResolver: true,
|
IsResolver: true,
|
||||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
return nil, errors.New("field of type Void does not have child fields")
|
switch field.Name {
|
||||||
|
case "vendorEdge":
|
||||||
|
return ec.fieldContext_DeleteVendorPayload_vendorEdge(ctx, field)
|
||||||
|
case "deletedVendorId":
|
||||||
|
return ec.fieldContext_DeleteVendorPayload_deletedVendorId(ctx, field)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("no field named %q was found under type DeleteVendorPayload", field.Name)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
@@ -10566,6 +10679,50 @@ func (ec *executionContext) _CreateVendorPayload(ctx context.Context, sel ast.Se
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deleteVendorPayloadImplementors = []string{"DeleteVendorPayload"}
|
||||||
|
|
||||||
|
func (ec *executionContext) _DeleteVendorPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteVendorPayload) graphql.Marshaler {
|
||||||
|
fields := graphql.CollectFields(ec.OperationContext, sel, deleteVendorPayloadImplementors)
|
||||||
|
|
||||||
|
out := graphql.NewFieldSet(fields)
|
||||||
|
deferred := make(map[string]*graphql.FieldSet)
|
||||||
|
for i, field := range fields {
|
||||||
|
switch field.Name {
|
||||||
|
case "__typename":
|
||||||
|
out.Values[i] = graphql.MarshalString("DeleteVendorPayload")
|
||||||
|
case "vendorEdge":
|
||||||
|
out.Values[i] = ec._DeleteVendorPayload_vendorEdge(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
case "deletedVendorId":
|
||||||
|
out.Values[i] = ec._DeleteVendorPayload_deletedVendorId(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
|
out.Invalids++
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.Dispatch(ctx)
|
||||||
|
if out.Invalids > 0 {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic.AddInt32(&ec.deferred, int32(len(deferred)))
|
||||||
|
|
||||||
|
for label, dfs := range deferred {
|
||||||
|
ec.processDeferredGroup(graphql.DeferredGroup{
|
||||||
|
Label: label,
|
||||||
|
Path: graphql.GetPath(ctx),
|
||||||
|
FieldSet: dfs,
|
||||||
|
Context: ctx,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
var evidenceImplementors = []string{"Evidence", "Node"}
|
var evidenceImplementors = []string{"Evidence", "Node"}
|
||||||
|
|
||||||
func (ec *executionContext) _Evidence(ctx context.Context, sel ast.SelectionSet, obj *types.Evidence) graphql.Marshaler {
|
func (ec *executionContext) _Evidence(ctx context.Context, sel ast.SelectionSet, obj *types.Evidence) graphql.Marshaler {
|
||||||
@@ -12720,6 +12877,20 @@ func (ec *executionContext) unmarshalNDeleteVendorInput2githubᚗcomᚋgetprobo
|
|||||||
return res, graphql.ErrorOnPath(ctx, err)
|
return res, graphql.ErrorOnPath(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNDeleteVendorPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteVendorPayload(ctx context.Context, sel ast.SelectionSet, v types.DeleteVendorPayload) graphql.Marshaler {
|
||||||
|
return ec._DeleteVendorPayload(ctx, sel, &v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNDeleteVendorPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteVendorPayload(ctx context.Context, sel ast.SelectionSet, v *types.DeleteVendorPayload) graphql.Marshaler {
|
||||||
|
if v == nil {
|
||||||
|
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||||
|
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||||
|
}
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
return ec._DeleteVendorPayload(ctx, sel, v)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalNEvidence2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidence(ctx context.Context, sel ast.SelectionSet, v *types.Evidence) graphql.Marshaler {
|
func (ec *executionContext) marshalNEvidence2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidence(ctx context.Context, sel ast.SelectionSet, v *types.Evidence) graphql.Marshaler {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ type DeleteVendorInput struct {
|
|||||||
VendorID gid.GID `json:"vendorId"`
|
VendorID gid.GID `json:"vendorId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteVendorPayload struct {
|
||||||
|
VendorEdge *VendorEdge `json:"vendorEdge"`
|
||||||
|
DeletedVendorID gid.GID `json:"deletedVendorId"`
|
||||||
|
}
|
||||||
|
|
||||||
type Evidence struct {
|
type Evidence struct {
|
||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
FileURL string `json:"fileUrl"`
|
FileURL string `json:"fileUrl"`
|
||||||
|
|||||||
@@ -110,13 +110,15 @@ func (r *mutationResolver) UpdateVendor(ctx context.Context, input types.UpdateV
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteVendor is the resolver for the deleteVendor field.
|
// DeleteVendor is the resolver for the deleteVendor field.
|
||||||
func (r *mutationResolver) DeleteVendor(ctx context.Context, input types.DeleteVendorInput) (string, error) {
|
func (r *mutationResolver) DeleteVendor(ctx context.Context, input types.DeleteVendorInput) (*types.DeleteVendorPayload, error) {
|
||||||
err := r.svc.DeleteVendor(ctx, input.VendorID)
|
err := r.svc.DeleteVendor(ctx, input.VendorID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("cannot delete vendor: %w", err)
|
return nil, fmt.Errorf("cannot delete vendor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", nil
|
return &types.DeleteVendorPayload{
|
||||||
|
DeletedVendorID: input.VendorID,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatePeople is the resolver for the createPeople field.
|
// CreatePeople is the resolver for the createPeople field.
|
||||||
|
|||||||
Reference in New Issue
Block a user