-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Setup AI Mocking packages #12854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Setup AI Mocking packages #12854
Conversation
|
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 6 changed, 0 removed
Build ID: 03178d0e403d3532b41b8986 URL: https://www.apollographql.com/docs/deploy-preview/03178d0e403d3532b41b8986 |
8d7be3a
to
adbc5f6
Compare
commit: |
size-limit report 📦
|
adbc5f6
to
418df18
Compare
a58e19a
to
3cbe6a6
Compare
0e533af
to
a6ca40f
Compare
This PR adds new packages to the Apollo Client repo for AI Mocking.
@apollo/client-ai
— This package provides tooling to mock API responses using AI@apollo/client-ai-vercel-adapter
— This package provides a Vercel SDK adapter to use with the@apollo/client-ai
tools. This separation ensures the core AI tools are provider agnostic.Use
AIMockedProvider
You can set up your client app to use mock data by using the
AIMockedProvider
(similar to theMockProvider
, only without static mocks):This provider uses the
AIMockLink
to intercept the GraphQL operations performed by Apollo Client and instead fulfill them using AI.AIMockLink
You can plug
AIMockLink
directly into your Apollo Client as well, bypassing theAIMockedProvider
component:VercelAIAdapter
The
VercelAIAdapter
creates an AI adapter for the Vercel AI SDK. It supports choosing the model you want to use for generating mock data:When
model
is provided as a string, the user will need to refer to the Vercel AI SDK provider docs to see what the ENV variable for the specific API key for their provider needs to be. For example, OpenAI looks for theOPENAI_API_KEY
env variable:Users can also configure a specific provider object and pass it in, which would allow them to more directly configure the API key as an option. For example: