Skip to content

Commit

Permalink
Auto-generate query and types for DevStoresByOrg
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloriestra committed Sep 10, 2024
1 parent 30b000f commit af722c0
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 51 deletions.
43 changes: 0 additions & 43 deletions packages/app/src/cli/api/graphql/all_dev_stores_by_org.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* 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 DevStoresByOrgQueryVariables = Types.Exact<{
id: Types.Scalars['ID']['input']
}>

export type DevStoresByOrgQuery = {
organizations: {
nodes?:
| ({
id: string
stores: {
nodes?:
| ({
shopId?: string | null
link: unknown
shopDomain: string
shopName: string
transferDisabled: boolean
convertableToPartnerTest: boolean
} | null)[]
| null
}
} | null)[]
| null
}
}

export const DevStoresByOrg = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: {kind: 'Name', value: 'DevStoresByOrg'},
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'id'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'ID'}}},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'organizations'},
arguments: [
{
kind: 'Argument',
name: {kind: 'Name', value: 'id'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'id'}},
},
{kind: 'Argument', name: {kind: 'Name', value: 'first'}, value: {kind: 'IntValue', value: '1'}},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'nodes'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: 'id'}},
{
kind: 'Field',
name: {kind: 'Name', value: 'stores'},
arguments: [
{
kind: 'Argument',
name: {kind: 'Name', value: 'first'},
value: {kind: 'IntValue', value: '500'},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'archived'},
value: {kind: 'BooleanValue', value: false},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'type'},
value: {
kind: 'ListValue',
values: [
{kind: 'EnumValue', value: 'DEVELOPMENT'},
{kind: 'EnumValue', value: 'MANAGED'},
{kind: 'EnumValue', value: 'PLUS_SANDBOX'},
],
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'nodes'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: 'shopId'}},
{kind: 'Field', name: {kind: 'Name', value: 'link'}},
{kind: 'Field', name: {kind: 'Name', value: 'shopDomain'}},
{kind: 'Field', name: {kind: 'Name', value: 'shopName'}},
{kind: 'Field', name: {kind: 'Name', value: 'transferDisabled'}},
{kind: 'Field', name: {kind: 'Name', value: 'convertableToPartnerTest'}},
{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<DevStoresByOrgQuery, DevStoresByOrgQueryVariables>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query DevStoresByOrg($id: ID!) {
organizations(id: $id, first: 1) {
nodes {
id
stores(first: 500, archived: false, type: [DEVELOPMENT, MANAGED, PLUS_SANDBOX]) {
nodes {
shopId
link
shopDomain
shopName
transferDisabled
convertableToPartnerTest
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {CreateAppQuery, CreateAppQuerySchema, CreateAppQueryVariables} from '../../api/graphql/create_app.js'
import {
AllDevStoresByOrganizationQuery,
AllDevStoresByOrganizationQueryVariables,
AllDevStoresByOrganizationSchema,
} from '../../api/graphql/all_dev_stores_by_org.js'
import {
ActiveAppVersion,
AppDeployOptions,
Expand Down Expand Up @@ -151,6 +146,11 @@ import {
FindOrganizationQueryVariables,
} from '../../api/graphql/find_org.js'
import {NoOrgError} from '../../services/dev/fetch.js'
import {
DevStoresByOrg,
DevStoresByOrgQuery,
DevStoresByOrgQueryVariables,
} from '../../api/graphql/partners/generated/dev-stores-by-org.js'
import {
FunctionUploadUrlGenerate,
FunctionUploadUrlGenerateMutation,
Expand Down Expand Up @@ -359,9 +359,9 @@ export class PartnersClient implements DeveloperPlatformClient {
}

async devStoresForOrg(orgId: string): Promise<OrganizationStore[]> {
const variables: AllDevStoresByOrganizationQueryVariables = {id: orgId}
const result: AllDevStoresByOrganizationSchema = await this.request(AllDevStoresByOrganizationQuery, variables)
return result.organizations.nodes[0]!.stores.nodes
const variables: DevStoresByOrgQueryVariables = {id: orgId}
const result: DevStoresByOrgQuery = await this.requestDoc(DevStoresByOrg, variables)
return result.organizations.nodes![0]!.stores.nodes as OrganizationStore[]
}

async appExtensionRegistrations(
Expand Down

0 comments on commit af722c0

Please sign in to comment.