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

[prototype] Import declarative webhooks #4466

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions bin/get-graphql-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ const schemas = [
repo: 'shopify',
pathToFile: 'db/graphql/app_dev_schema_unstable_public.graphql',
localPath: './packages/app/src/cli/api/graphql/app-dev/app_dev_schema.graphql',
}
},
{
repo: 'shopify',
pathToFile: 'db/graphql/admin_schema_unstable_public.graphql',
localPath: './packages/app/src/cli/api/graphql/admin/admin_schema.graphql',
},
]

function runCommand(command, args) {
Expand Down Expand Up @@ -69,16 +74,16 @@ function extractPassword(output) {
async function fetchFileForSchema(schema, octokit) {
try {
// Fetch the file content from the repository
const {data} = await octokit.repos.getContent({
const {data: content} = await octokit.repos.getContent({
owner: OWNER,
repo: schema.repo,
path: schema.pathToFile,
ref: BRANCH,
headers: {
Accept: 'application/vnd.github.raw+json',
},
})

// Decode the base64 content
const content = Buffer.from(data.content, 'base64').toString('utf-8')

// Define the local path where the file will be saved
const localFilePath = schema.localPath

Expand Down
1 change: 1 addition & 0 deletions graphql.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ export default {
businessPlatformDestinations: projectFactory('business-platform-destinations', 'destinations_schema.graphql'),
businessPlatformOrganizations: projectFactory('business-platform-organizations', 'organizations_schema.graphql'),
appDev: projectFactory('app-dev', 'app_dev_schema.graphql'),
admin: projectFactory('admin', 'admin_schema.graphql'),
},
}
27 changes: 22 additions & 5 deletions packages/app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@
"{projectRoot}/src/cli/api/graphql/partners/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/business-platform-destinations/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/business-platform-organizations/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/app-dev/generated/**/*.ts"
"{projectRoot}/src/cli/api/graphql/app-dev/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"
],
"options": {
"commands": [
"pnpm eslint 'src/cli/api/graphql/partners/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/app-dev/generated/**/*.{ts,tsx}' --fix"
"pnpm eslint 'src/cli/api/graphql/app-dev/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix"
],
"cwd": "packages/app"
}
Expand Down Expand Up @@ -135,26 +137,41 @@
"cwd": "{workspaceRoot}"
}
},
"graphql-codegen:generate:admin": {
"executor": "nx:run-commands",
"inputs": ["{workspaceRoot}/graphql.config.ts", "{projectRoot}/src/cli/api/graphql/admin/**/*.graphql"],
"outputs": ["{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"],
"options": {
"commands": [
"pnpm exec graphql-codegen --project=admin"
],
"cwd": "{workspaceRoot}"
}
},
"graphql-codegen:postfix": {
"executor": "nx:run-commands",
"dependsOn": [
"graphql-codegen:generate:partners",
"graphql-codegen:generate:business-platform-destinations",
"graphql-codegen:generate:business-platform-organizations",
"graphql-codegen:generate:app-dev"
"graphql-codegen:generate:app-dev",
"graphql-codegen:generate:admin"
],
"inputs": [{ "dependentTasksOutputFiles": "**/*.ts" }],
"outputs": [
"{projectRoot}/src/cli/api/graphql/partners/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/business-platform-destinations/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/business-platform-organizations/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/app-dev/generated/**/*.ts"],
"{projectRoot}/src/cli/api/graphql/app-dev/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"
],
"options": {
"commands": [
"find ./packages/app/src/cli/api/graphql/partners/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
"find ./packages/app/src/cli/api/graphql/business-platform-destinations/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
"find ./packages/app/src/cli/api/graphql/business-platform-organizations/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
"find ./packages/app/src/cli/api/graphql/app-dev/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;"
"find ./packages/app/src/cli/api/graphql/app-dev/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;",
"find ./packages/app/src/cli/api/graphql/admin/generated/ -type f -name '*.ts' -exec sh -c 'sed -i \"\" \"s|import \\* as Types from '\\''./types'\\'';|import \\* as Types from '\\''./types.js'\\'';|g; s|export const \\([A-Za-z0-9_]*\\)Document =|export const \\1 =|g\" \"$0\"' {} \\;"
],
"cwd": "{workspaceRoot}"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions */
import * as Types from './types.js'

import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'

export type ListWebhookSubscriptionsQueryVariables = Types.Exact<{[key: string]: never}>

export type ListWebhookSubscriptionsQuery = {
webhookSubscriptions: {
edges: {
node: {
topic: Types.WebhookSubscriptionTopic
endpoint:
| {__typename: 'WebhookEventBridgeEndpoint'}
| {__typename: 'WebhookHttpEndpoint'; callbackUrl: unknown}
| {__typename: 'WebhookPubSubEndpoint'}
}
}[]
}
}

export const ListWebhookSubscriptions = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: {kind: 'Name', value: 'ListWebhookSubscriptions'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'webhookSubscriptions'},
arguments: [
{kind: 'Argument', name: {kind: 'Name', value: 'first'}, value: {kind: 'IntValue', value: '100'}},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'edges'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'node'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: 'topic'}},
{
kind: 'Field',
name: {kind: 'Name', value: 'endpoint'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
{
kind: 'InlineFragment',
typeCondition: {
kind: 'NamedType',
name: {kind: 'Name', value: 'WebhookHttpEndpoint'},
},
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: 'callbackUrl'}},
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
],
},
},
],
},
},
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
],
},
},
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
],
},
},
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
],
},
},
],
},
},
],
} as unknown as DocumentNode<ListWebhookSubscriptionsQuery, ListWebhookSubscriptionsQueryVariables>
Loading
Loading