@apollo/client-ai-apps 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ var ExtendedApolloClient = class extends ApolloClient {
116
116
  }
117
117
  async prefetchData() {
118
118
  this.manifest.operations.forEach((operation) => {
119
- if (operation.prefetch && operation.prefetchID && window.openai.toolOutput.prefetch[operation.prefetchID]) {
119
+ if (operation.prefetch && operation.prefetchID && window.openai.toolOutput.prefetch?.[operation.prefetchID]) {
120
120
  this.writeQuery({
121
121
  query: parse(operation.body),
122
122
  data: window.openai.toolOutput.prefetch[operation.prefetchID].data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client-ai-apps",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -59,7 +59,7 @@ export class ExtendedApolloClient extends ApolloClient {
59
59
  async prefetchData() {
60
60
  // Write prefetched data to the cache
61
61
  this.manifest.operations.forEach((operation) => {
62
- if (operation.prefetch && operation.prefetchID && window.openai.toolOutput.prefetch[operation.prefetchID]) {
62
+ if (operation.prefetch && operation.prefetchID && window.openai.toolOutput.prefetch?.[operation.prefetchID]) {
63
63
  this.writeQuery({
64
64
  query: parse(operation.body),
65
65
  data: window.openai.toolOutput.prefetch[operation.prefetchID].data,
@@ -0,0 +1,13 @@
1
+ import { expect, test, vi } from "vitest";
2
+ import { useToolInput } from "./useToolInput";
3
+ import { renderHook, act } from "@testing-library/react";
4
+
5
+ test("Should return tool input when called", async () => {
6
+ vi.stubGlobal("openai", {
7
+ toolInput: { name: "John" },
8
+ });
9
+
10
+ const { result } = renderHook(() => useToolInput());
11
+
12
+ expect(result.current).toEqual({ name: "John" });
13
+ });