Skip to content
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

refactor: update to @prismicio/client v7 #46

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file removed examples/.gitkeep
Empty file.
100 changes: 32 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
},
"dependencies": {
"@prismicio/client": "^6.4.1"
"@prismicio/client": "^7.0.1"
},
"devDependencies": {
"@apollo/client": "^3.5.8",
"@prismicio/types": "^0.1.24",
"@size-limit/preset-small-lib": "^7.0.8",
"@types/node-fetch": "^2.6.0",
"@types/sinon": "^10.0.11",
Expand Down
3 changes: 2 additions & 1 deletion src/createPrismicLink.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ApolloLink, HttpOptions } from "@apollo/client/core";
import { FetchLike, getRepositoryName } from "@prismicio/client";
import { createHttpLink } from "@apollo/client/core";
import {
FetchLike,
getRepositoryName,
getRepositoryEndpoint,
getGraphQLEndpoint,
createClient,
Expand Down
14 changes: 7 additions & 7 deletions test/createPrismicLink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ref = repositoryResponse.refs?.[0].ref as string;

test("creates an HTTP Link from a repositoryName", async (t) => {
const repositoryName = "qwerty";
const apiEndpoint = prismic.getEndpoint(repositoryName);
const apiEndpoint = prismic.getRepositoryEndpoint(repositoryName);
const uri = prismic.getGraphQLEndpoint(repositoryName);

const query = gql`
Expand All @@ -62,7 +62,7 @@ test("creates an HTTP Link from a repositoryName", async (t) => {
`;
const compressedQuery = `{foo}`;

const fetch = sinon.stub().callsFake((url) => {
const fetch = sinon.stub().callsFake(async (url) => {
const instance = new URL(url);

if (url === apiEndpoint) {
Expand Down Expand Up @@ -95,7 +95,7 @@ test("creates an HTTP Link from a repositoryName", async (t) => {

test("supports only a uri option", async (t) => {
const repositoryName = "qwerty";
const apiEndpoint = prismic.getEndpoint(repositoryName);
const apiEndpoint = prismic.getRepositoryEndpoint(repositoryName);
const uri = prismic.getGraphQLEndpoint(repositoryName);

const query = gql`
Expand All @@ -105,7 +105,7 @@ test("supports only a uri option", async (t) => {
`;
const compressedQuery = `{foo}`;

const fetch = sinon.stub().callsFake((url) => {
const fetch = sinon.stub().callsFake(async (url) => {
const instance = new URL(url);

if (url === apiEndpoint) {
Expand Down Expand Up @@ -165,7 +165,7 @@ test("supports custom API endpoint (for Rest API)", async (t) => {
`;
const compressedQuery = `{foo}`;

const fetch = sinon.stub().callsFake((url) => {
const fetch = sinon.stub().callsFake(async (url) => {
const instance = new URL(url);

if (url === apiEndpoint) {
Expand Down Expand Up @@ -199,7 +199,7 @@ test("supports custom API endpoint (for Rest API)", async (t) => {

test("supports custom GraphQL endpoint", async (t) => {
const repositoryName = "qwerty";
const apiEndpoint = prismic.getEndpoint(repositoryName);
const apiEndpoint = prismic.getRepositoryEndpoint(repositoryName);
const uri = "https://example.com/";

const query = gql`
Expand All @@ -209,7 +209,7 @@ test("supports custom GraphQL endpoint", async (t) => {
`;
const compressedQuery = `{foo}`;

const fetch = sinon.stub().callsFake((url) => {
const fetch = sinon.stub().callsFake(async (url) => {
const instance = new URL(url);

if (url === apiEndpoint) {
Expand Down