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

Add shopify-app-remix scopes API documentation #1506

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

RyanDJLee
Copy link
Contributor

@RyanDJLee RyanDJLee commented Sep 13, 2024

#gsd:39564

WHY are these changes introduced?

Spin url: https://shopify-dev.shopify-dev-3h44.allen-chazhoor.us.spin.dev/docs/api/shopify-app-remix/v3/apis/scopes
(resume on Spin Control if necessary)

WHAT is this pull request doing?

image
image
image
image

Type of change

Documentation

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have used pnpm changeset to create a draft changelog entry (do NOT update the CHANGELOG.md files manually)
  • I have added/updated tests for this change
  • I have documented new APIs/updated the documentation for modified APIs (for public APIs)

Ryan DJ Lee and others added 3 commits September 12, 2024 15:27
Co-authored-by: Jonathan J Chang <jonathan.j.chang@shopify.com>
Co-authored-by: Allen Chazhoor <allen.chazhoor@shopify.com>
…uery

Co-authored-by: Allen Chazhoor <allen.chazhoor@shopify.com>
@@ -32,6 +32,7 @@ const data: ReferenceEntityTemplateSchema = {
'EmbeddedAdminContext',
'AdminApiContext',
'BillingContext',
'ScopesApiContext',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page with these examples is so weird. There are no headers between the sets of examples, so it looks like everything is related, even though there are billing things mixed in with scopes. Maybe not something for us to fix, but it feels like something to flag to Learn?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, this page is problematic.
+1, not necessarily something we need to fix here, but would be great to rethink this page & its purpose

const data: ReferenceEntityTemplateSchema = {
name: 'Scopes',
description:
'Contains functions used to manage optional scopes for your app.\n\nThis object is returned on authenticated Admin requests.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Contains functions used to manage optional scopes for your app.\n\nThis object is returned on authenticated Admin requests.',
'Contains functions used to manage scopes for your app.\n\nThis object is returned on authenticated Admin requests.',

I remember Jake making a point to say that this was the "scopes api", not the "optional scopes api". What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate question: how are scopes managed for the storefront API? We don't want optional scopes for the storefront API, right?

Copy link

@kbav kbav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love seeing this and all the work you've put into it, Ryan! Thank you for working on this 🙌

I'm in process of reviewing this and I have a dumb question... but where does the code for the examples on the right live?

For example, for the query method, I was going to propose a few changes

  • rather than set up a Resource Route we POST to for retrieving data through action, we could show using a Resource Route for retrieving data through loader. The useRouteLoaderData hook can be used for scenarios like this to then pull in data from other routes
  • request method example was a bit convoluted (may be clearer to just have an action and button on the same page, instead of using a Resource Route) and not clear that it leads to a full page redirect.

I was about to write "similar to the above" for the revoke method but now I'm wondering if it would just be overall better to demonstrate these being used in loaders and actions right on the same page. It’s a bit less mental overhead for looking at the examples, and would change the examples from having 3 tabs/files to 2 tabs/files — importantly, with all the relevant details in the first/visible tab.

What do you think about that suggestion?

@@ -32,6 +32,7 @@ const data: ReferenceEntityTemplateSchema = {
'EmbeddedAdminContext',
'AdminApiContext',
'BillingContext',
'ScopesApiContext',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, this page is problematic.
+1, not necessarily something we need to fix here, but would be great to rethink this page & its purpose

@allenchazhoor
Copy link
Contributor

allenchazhoor commented Sep 27, 2024

@RyanDJLee
Copy link
Contributor Author

I'm in process of reviewing this and I have a dumb question... but where does the code for the examples on the right live?

No worries, it's different from ABN docs in that the code examples are directly in the docstring here. I think the current docs on the Spin instance are also outdated as we decided to remove the button examples per Pierre's feedback and to be more consistent with the rest of the documentation that simply show an action or loader.

rather than set up a Resource Route we POST to for retrieving data through action, we could show using a Resource Route for retrieving data through loader. The useRouteLoaderData hook can be used for scenarios like this to then pull in data from other routes
request method example was a bit convoluted (may be clearer to just have an action and button on the same page, instead of using a Resource Route) and not clear that it leads to a full page redirect.

I'm on board with using a Resource Route like Billing here. We chose to use an action as it is consistent with our getting started app, but we should use the correct primitives that Remix provides.

I was about to write "similar to the above" for the revoke method but now I'm wondering if it would just be overall better to demonstrate these being used in loaders and actions right on the same page. It’s a bit less mental overhead for looking at the examples, and would change the examples from having 3 tabs/files to 2 tabs/files — importantly, with all the relevant details in the first/visible tab.

I address this in the first part of my response above - we did choose to remove the button completely and reduce to 2 tabs with a focus on just the action. Apologies for not updating the instance.

What do you think about that suggestion?
cc @allenchazhoor

@allenchazhoor
Copy link
Contributor

I've replaced the usage of actions to use loaders. Because we removed the button files, I believe the examples in their current state are accurate but please let me know if more additions/adjustments need to be made.

cc @RyanDJLee @kbav

@allenchazhoor
Copy link
Contributor

There is also this comment from the App Bridge PR that I believe is relevant here

Copy link

@kbav kbav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I steered you wrong re: converting all to use loader; if I did, I meant to just request that for the query example. I think the other two could leverage a resource route pattern, much like Ryan & co. leveraged for making the optional scopes test app

*
*import { authenticate } from "../shopify.server";
*import { AuthScopes } from "@shopify/shopify-api";
*export async function loader({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the context below, it looks like this is being set up more specifically as an action: request.formData(), etc.

I think the query makes sense in a loader, but request perhaps best makes sense as part of a resource route's action, and perhaps the same for revoke. Worth testing for those

/**
* Revokes the provided scopes from this app on this shop
*
* **Warning:** This method throws an [error](https://shopify.dev/docs/api/admin-graphql/unstable/objects/AppRevokeAccessScopesAppRevokeScopeError) if the provided optional scopes contains a required scope.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If other API’s don't use this pattern of adding a bolded "Warning", I'd consider dropping the word entirely

@allenchazhoor allenchazhoor changed the title [WIP] add shopify-app-remix scopes API documentation Add shopify-app-remix scopes API documentation Oct 7, 2024
@allenchazhoor allenchazhoor marked this pull request as ready for review October 7, 2024 14:09
@allenchazhoor allenchazhoor requested a review from a team as a code owner October 7, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants