0

I got empty object while uploading image. I follow all the step provided, but still can't make it solve. The error said "Variable "$file" got invalid value {}; Upload value invalid."

 const client = createClient({
    url: import.meta.env.VITE_BASE_API_URL ?? '',
    exchanges: [
      ...defaultExchanges,
      dedupExchange,
      cacheExchange,
      subscriptionExchange({
        forwardSubscription: (operation) => ({
          subscribe: (sink) => ({
            unsubscribe: wsClient.subscribe(operation, sink),
          }),
        }),
      }),
      refocusExchange(),
      multipartFetchExchange,
    ],
  });

export const UPLOAD_WORKER_IMAGE = gql`
  mutation setImage($file: Upload!, $workerId: UUID!) {
    updateWorker(input: { patch: { imageUrl: $file }, id: $workerId }) {
      }
    }
  }
`;


  // Upload.tsx

  const [, mutateWorkerImage] = useMutation<UpdateWorker>(UPLOAD_WORKER_IMAGE);

 const file = bindData.avatarFile;
    const { error: errorUploadImage, data } = await mutateWorkerImage({
      workerId: dataWorker.createWorker.worker.id,
      file: file,
    });
surya kumara
  • 185
  • 1
  • 11

0 Answers0