Skip to content
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
6 changes: 6 additions & 0 deletions bin/get-graphql-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ const schemas = [
pathToFile: 'areas/core/shopify/db/graphql/app_management_schema_unstable_public.graphql',
localPaths: ['./packages/app/src/cli/api/graphql/app-management/app_management_schema.graphql'],
},
{
owner: 'shop',
repo: 'world',
pathToFile: 'areas/core/shopify/db/graphql/app_logs_schema_unstable_public.graphql',
localPaths: ['./packages/app/src/cli/api/graphql/app-logs/app_logs_schema.graphql'],
},
{
owner: 'shop',
repo: 'world',
Expand Down
5 changes: 4 additions & 1 deletion graphql.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function projectFactory(name: string, schemaName: string, project: string = 'app') {
function projectFactory(name: string, schemaName: string, project: string = 'app', scalars: Record<string, string> = {}) {
return {
schema: `./packages/${project}/src/cli/api/graphql/${name}/${schemaName}`,
documents: [
Expand Down Expand Up @@ -26,6 +26,7 @@ function projectFactory(name: string, schemaName: string, project: string = 'app
PropertyPublicID: 'string',
JSON: {input: 'JsonMapType | string', output: 'JsonMapType'},
URL: 'string',
...scalars,
},
},
},
Expand All @@ -50,6 +51,7 @@ function projectFactory(name: string, schemaName: string, project: string = 'app
PropertyPublicID: 'string',
JSON: {input: 'JsonMapType | string', output: 'JsonMapType'},
URL: 'string',
...scalars,
},
},
},
Expand Down Expand Up @@ -79,6 +81,7 @@ export default {
businessPlatformOrganizations: projectFactory('business-platform-organizations', 'organizations_schema.graphql'),
appDev: projectFactory('app-dev', 'app_dev_schema.graphql'),
appManagement: projectFactory('app-management', 'app_management_schema.graphql'),
appLogs: projectFactory('app-logs', 'app_logs_schema.graphql', 'app', {DateTime: 'string'}),
admin: projectFactory('admin', 'admin_schema.graphql', 'cli-kit'),
bulkOperations: projectFactory('bulk-operations', 'admin_schema.graphql', 'cli-kit'),
webhooks: projectFactory('webhooks', 'webhooks_schema.graphql'),
Expand Down
14 changes: 14 additions & 0 deletions packages/app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"{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-management/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/app-logs/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/webhooks/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/functions/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"
Expand All @@ -78,6 +79,7 @@
"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-management/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/app-logs/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/webhooks/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/functions/generated/**/*.{ts,tsx}' --fix",
"pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix"
Expand Down Expand Up @@ -148,6 +150,15 @@
"cwd": "{workspaceRoot}"
}
},
"graphql-codegen:generate:app-logs": {
"executor": "nx:run-commands",
"inputs": ["{workspaceRoot}/graphql.config.ts", "{projectRoot}/src/cli/api/graphql/app-logs/**/*.graphql", "sharedGlobals"],
"outputs": ["{projectRoot}/src/cli/api/graphql/app-logs/generated/**/*.ts"],
"options": {
"commands": ["pnpm exec graphql-codegen --project=appLogs"],
"cwd": "{workspaceRoot}"
}
},
"graphql-codegen:generate:functions": {
"executor": "nx:run-commands",
"inputs": ["{workspaceRoot}/graphql.config.ts", "{projectRoot}/src/cli/api/graphql/functions/**/*.graphql", "sharedGlobals"],
Expand Down Expand Up @@ -177,6 +188,7 @@
"graphql-codegen:generate:business-platform-organizations",
"graphql-codegen:generate:app-dev",
"graphql-codegen:generate:app-management",
"graphql-codegen:generate:app-logs",
"graphql-codegen:generate:webhooks",
"graphql-codegen:generate:functions",
"graphql-codegen:generate:admin-as-app"
Expand All @@ -187,6 +199,7 @@
"{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-management/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/app-logs/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/webhooks/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/functions/generated/**/*.ts",
"{projectRoot}/src/cli/api/graphql/admin/generated/**/*.ts"
Expand All @@ -197,6 +210,7 @@
"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-management/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-logs/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/webhooks/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/functions/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\"' {} \\;"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions */
import * as Types from './types.js'
import {JsonMapType} from '@shopify/cli-kit/node/toml'

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

export type HistoricalLogsQueryVariables = Types.Exact<{
clientId: Types.Scalars['String']['input']
types: Types.LogEventType[] | Types.LogEventType
timestamp: Types.TimestampRangeInput
limit: Types.Scalars['Int']['input']
filters?: Types.InputMaybe<Types.LogFilterInput[] | Types.LogFilterInput>
sortKey?: Types.InputMaybe<Types.LogSortKeys>
reverse?: Types.InputMaybe<Types.Scalars['Boolean']['input']>
}>

export type HistoricalLogsQuery = {
app?: {logs?: {records: ({json: JsonMapType} | {json: JsonMapType})[]} | null} | null
}

export const HistoricalLogs = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: {kind: 'Name', value: 'HistoricalLogs'},
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'clientId'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}}},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'types'}},
type: {
kind: 'NonNullType',
type: {
kind: 'ListType',
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'LogEventType'}}},
},
},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'timestamp'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'TimestampRangeInput'}}},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'limit'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'Int'}}},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'filters'}},
type: {
kind: 'ListType',
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'LogFilterInput'}}},
},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'sortKey'}},
type: {kind: 'NamedType', name: {kind: 'Name', value: 'LogSortKeys'}},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'reverse'}},
type: {kind: 'NamedType', name: {kind: 'Name', value: 'Boolean'}},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'app'},
arguments: [
{
kind: 'Argument',
name: {kind: 'Name', value: 'clientId'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'clientId'}},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'logs'},
arguments: [
{
kind: 'Argument',
name: {kind: 'Name', value: 'types'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'types'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'timestamp'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'timestamp'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'limit'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'limit'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'filters'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'filters'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'sortKey'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'sortKey'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'reverse'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'reverse'}},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'records'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: 'json'}},
{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<HistoricalLogsQuery, HistoricalLogsQueryVariables>
97 changes: 97 additions & 0 deletions packages/app/src/cli/api/graphql/app-logs/generated/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any, tsdoc/syntax, @typescript-eslint/no-duplicate-type-constituents, @typescript-eslint/no-redundant-type-constituents, @nx/enforce-module-boundaries */
import {JsonMapType} from '@shopify/cli-kit/node/toml'
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: { input: string; output: string; }
String: { input: string; output: string; }
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
/**
* Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string.
* For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is
* represented as `"2019-09-07T15:50:00Z`".
*/
DateTime: { input: string; output: string; }
/**
* A [JSON](https://www.json.org/json-en.html) object.
*
* Example value:
* `{
* "product": {
* "id": "gid://shopify/Product/1346443542550",
* "title": "White T-shirt",
* "options": [{
* "name": "Size",
* "values": ["M", "L"]
* }]
* }
* }`
*/
JSON: { input: JsonMapType | string; output: JsonMapType; }
};

/** A log type. */
export type LogEventType =
/** A GraphQL API request. */
| 'GRAPHQL_REQUEST'
/** A webhook delivery. */
| 'WEBHOOK_DELIVERY';

/**
* The fields logs can be filtered on. Each name matches a `shopify app logs` CLI
* flag or the record field it filters. A filter on a field that a log type doesn't
* have excludes that type's logs.
*/
export type LogFilterField =
/** The GraphQL operation name. Applies to GraphQL requests. */
| 'OPERATION_NAME'
/** The GraphQL operation type, such as query or mutation. Applies to GraphQL requests. */
| 'OPERATION_TYPE'
/** The API request ID. Applies to GraphQL requests. */
| 'REQUEST_ID'
/** The result: SUCCESS or FAILURE, as in resultStatus. The CLI's --status flag. Applies to every log type. */
| 'RESULT_STATUS'
/** The shop's myshopify.com domain, as in shopMyshopifyDomain. The CLI's --store flag. Applies to every log type. */
| 'SHOP_MYSHOPIFY_DOMAIN'
/** The HTTP response status code, such as 500. Applies to webhook deliveries. */
| 'STATUS_CODE'
/** The webhook topic, such as orders/create. Applies to webhook deliveries. */
| 'TOPIC';

/** The input fields for one logs filter. All filters are combined with AND. */
export type LogFilterInput = {
/** The field to filter on. */
field: LogFilterField;
/** How to compare the field with the value. */
operator: LogFilterOperator;
/** The value to compare with, at most 1024 bytes. */
value: Scalars['String']['input'];
};

/** How a filter compares a field with its value. */
export type LogFilterOperator =
/** Matches logs whose field equals the value. */
| 'EQUALS'
/** Matches logs whose field doesn't equal the value, including logs with no value for the field. */
| 'NOT_EQUALS';

/** The fields to sort logs by. */
export type LogSortKeys =
/** Sort by timestamp. */
| 'TIMESTAMP';

/** The input fields for a time range of up to 7 days within the last 30 days. */
export type TimestampRangeInput = {
/** The start of the range, inclusive. */
gte: Scalars['DateTime']['input'];
/** The end of the range, exclusive. */
lt: Scalars['DateTime']['input'];
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query HistoricalLogs(
$clientId: String!
$types: [LogEventType!]!
$timestamp: TimestampRangeInput!
$limit: Int!
$filters: [LogFilterInput!]
$sortKey: LogSortKeys
$reverse: Boolean
) {
app(clientId: $clientId) {
logs(types: $types, timestamp: $timestamp, limit: $limit, filters: $filters, sortKey: $sortKey, reverse: $reverse) {
records {
json
}
}
}
}
Loading
Loading