feat: new graphql method on the client, wrapping graphql calls for the gapi endpoint #868
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request type
New feature
How to test this PR
graphql()
methodWhat is the new behavior?
This introduces a simple wrapper
graphql()
that can be used to make GraphQL calls preserving the StoryblokClient instance instead of having to initialize a new one.This is useful when you have a shared instance of the client and cannot re-initialize for each call.
Other information
This PR does not break existing implementations because it just adds a new method.
This also introduces an interface for the Storyblok Class for better typings.
Note
This new wrapper is not mandatory, users can still call the gapi with custom calls or use the Client with REST apis.
However, this should let us fix an issue that some users raised with the
storyblok-react
SDK, when used with Next.js App Router and Server Components: some users are using the SDK but adding custom GraphQL calls, making it difficult for them to mix the two approaches. Here they can wrap their calls while preserving the Client instance.