Skip to content

Commit

Permalink
Preparing for release
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomarg committed Feb 12, 2024
1 parent 508b47b commit b44625b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
98 changes: 49 additions & 49 deletions packages/shopify-app-remix/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@
When using variables, `data` needs to be an object containing `query` and `variables`.

```ts
import { json, ActionFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";
import {json, ActionFunctionArgs} from '@remix-run/node';
import {authenticate} from '../shopify.server';

export async function action({ request }: ActionFunctionArgs) {
const { admin } = await authenticate.webhook(request);
export async function action({request}: ActionFunctionArgs) {
const {admin} = await authenticate.webhook(request);

const response = await admin?.graphql.query<any>({
data: {
Expand All @@ -158,23 +158,23 @@
}
}
}`,
variables: { input: { title: "Product Name" } },
variables: {input: {title: 'Product Name'}},
},
});

const productData = response?.body.data;
return json({ data: productData.data });
return json({data: productData.data});
}
```

With the `v3_webhookContext` flag enabled, `graphql` _is_ a function that takes in the query string and an optional settings object, including `variables`.

```ts
import { ActionFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";
import {ActionFunctionArgs} from '@remix-run/node';
import {authenticate} from '../shopify.server';

export async function action({ request }: ActionFunctionArgs) {
const { admin } = await authenticate.webhook(request);
export async function action({request}: ActionFunctionArgs) {
const {admin} = await authenticate.webhook(request);

const response = await admin?.graphql(
`#graphql
Expand All @@ -185,11 +185,11 @@
}
}
}`,
{ variables: { input: { title: "Product Name" } } },
{variables: {input: {title: 'Product Name'}}},
);

const productData = await response.json();
return json({ data: productData.data });
return json({data: productData.data});
}
```

Expand All @@ -215,12 +215,12 @@
<summary>App Proxy</summary>

```ts
import { json } from "@remix-run/node";
import { authenticate } from "~/shopify.server";
import {json} from '@remix-run/node';
import {authenticate} from '~/shopify.server';

export async function loader({ request }) {
const { storefront } = await authenticate.public.appProxy(request);
const response = await storefront.graphql("{blogs(first: 10) {nodes{id}}}");
export async function loader({request}) {
const {storefront} = await authenticate.public.appProxy(request);
const response = await storefront.graphql('{blogs(first: 10) {nodes{id}}}');

return json(await response.json());
}
Expand All @@ -232,17 +232,17 @@
<summary>Unauthenticated Storefront</summary>

```ts
import { json } from "@remix-run/node";
import { unauthenticated } from "~/shopify.server";
import { customAuthenticateRequest } from "~/helpers";
import {json} from '@remix-run/node';
import {unauthenticated} from '~/shopify.server';
import {customAuthenticateRequest} from '~/helpers';

export async function loader({ request }) {
export async function loader({request}) {
await customAuthenticateRequest(request);

const { storefront } = await unauthenticated.storefront(
"my-shop.myshopify.com",
const {storefront} = await unauthenticated.storefront(
'my-shop.myshopify.com',
);
const response = await storefront.graphql("{blogs(first: 10) {nodes{id}}}");
const response = await storefront.graphql('{blogs(first: 10) {nodes{id}}}');

return json(await response.json());
}
Expand All @@ -258,17 +258,17 @@
<summary>Override billing configs when calling <code>request</code></summary>

```ts
import { json } from "@remix-run/node";
import { authenticate } from "~/shopify.server";
import {json} from '@remix-run/node';
import {authenticate} from '~/shopify.server';

export async function loader({ request }) {
const { billing } = await authenticate.admin(request);
export async function loader({request}) {
const {billing} = await authenticate.admin(request);

await billing.require({
plans: ["plan1", "plan2"],
plans: ['plan1', 'plan2'],
onFailure: async () =>
await billing.request({
plan: "plan1",
plan: 'plan1',
trialDays: 5, // Override the trialDays config value
}),
});
Expand Down Expand Up @@ -300,12 +300,12 @@

```ts
// app/routes/**\/.ts
import { authenticate } from "~/shopify.server";
import {authenticate} from '~/shopify.server';

export async function loader({ request }) {
const { liquid, admin } = authenticate.public.appProxy(request);
export async function loader({request}) {
const {liquid, admin} = authenticate.public.appProxy(request);

return liquid("Hello {{shop.name}}");
return liquid('Hello {{shop.name}}');
}
```

Expand All @@ -316,12 +316,12 @@

```ts
// app/routes/**\/.ts
import { authenticate } from "~/shopify.server";
import {authenticate} from '~/shopify.server';

export async function loader({ request }) {
const { liquid, admin } = authenticate.public.appProxy(request);
export async function loader({request}) {
const {liquid, admin} = authenticate.public.appProxy(request);

const response = await admin.graphql("QUERY");
const response = await admin.graphql('QUERY');
const json = await response.json();

return json(json);
Expand Down Expand Up @@ -358,8 +358,8 @@

```ts
// app/shopify.server.ts
import { shopifyApp } from "@shopify/shopify-app-remix";
import { restResources } from "@shopify/shopify-api/rest/admin/2023-04";
import {shopifyApp} from '@shopify/shopify-app-remix';
import {restResources} from '@shopify/shopify-api/rest/admin/2023-04';

const shopify = shopifyApp({
restResources,
Expand All @@ -369,15 +369,15 @@
export default shopify;

// app/routes/\/.jsx
import { json } from "@remix-run/node";
import { authenticateExternalRequest } from "~/helpers/authenticate";
import shopify from "../../shopify.server";
import {json} from '@remix-run/node';
import {authenticateExternalRequest} from '~/helpers/authenticate';
import shopify from '../../shopify.server';

export async function loader({ request }) {
export async function loader({request}) {
const shop = await authenticateExternalRequest(request);
const { admin, session } = await shopify.unauthenticated.admin(shop);
const {admin, session} = await shopify.unauthenticated.admin(shop);

return json(await admin.rest.resources.Product.count({ session }));
return json(await admin.rest.resources.Product.count({session}));
}
```

Expand All @@ -391,10 +391,10 @@
<summary>See an example</summary>

```ts
export const loader = async ({ request }) => {
const { redirect } = await authenticate.admin(request);
export const loader = async ({request}) => {
const {redirect} = await authenticate.admin(request);

return redirect("https://www.example.com", { target: "_top" });
return redirect('https://www.example.com', {target: '_top'});
};
```

Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-app-remix/src/server/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SHOPIFY_REMIX_LIBRARY_VERSION = '2.5.0';
export const SHOPIFY_REMIX_LIBRARY_VERSION = '2.5.1';

0 comments on commit b44625b

Please sign in to comment.