Skip to content

Commit

Permalink
refactor: update to @prismicio/client v7 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Jun 6, 2023
1 parent d1f3fd5 commit a0d19d4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 78 deletions.
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
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
@@ -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
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

0 comments on commit a0d19d4

Please sign in to comment.