diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 78886f601..af6e404a3 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,5 +1,7 @@ /* eslint-env node */ +// eslint-disable-next-line @typescript-eslint/no-var-requires const guildConfig = require('@theguild/eslint-config/base'); +// eslint-disable-next-line @typescript-eslint/no-var-requires const { REACT_RESTRICTED_SYNTAX, RESTRICTED_SYNTAX } = require('@theguild/eslint-config/constants'); const rulesToExtends = Object.fromEntries( @@ -40,6 +42,8 @@ module.exports = { 'packages/web/app/src/graphql/index.ts', 'packages/libraries/cli/src/sdk.ts', 'packages/services/storage/src/db/types.ts', + 'codegen.cjs', + 'packages/web/app/src/gql/**/*', ], parserOptions: { ecmaVersion: 2020, diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 80c4a34ea..532c22d92 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -48,7 +48,7 @@ jobs: - name: Operation Check run: | npx graphql-inspector validate \ - "packages/web/app/**/*.graphql|packages/libraries/cli/**/*.graphql|packages/web/app/**/*.ts(x)" \ + "packages/web/app/**/*.graphql|packages/libraries/cli/**/*.graphql|packages/web/app/**/*.tsx|packages/web/app/src/lib/**/*.ts" \ "packages/**/module.graphql.ts" \ --maxDepth=20 \ --maxAliasCount=20 \ diff --git a/.prettierignore b/.prettierignore index b9d9642c9..a695d8263 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,8 +9,7 @@ __generated__/ /integration-tests/testkit/gql/ /packages/services/storage/src/db/types.ts /packages/libraries/cli/src/sdk.ts -/packages/web/app/src/gql/gql.d.ts -/packages/web/app/src/gql/graphql.ts +/packages/web/app/src/gql/** /packages/web/app/src/graphql/index.ts /packages/web/app/next.config.mjs diff --git a/codegen.cjs b/codegen.cjs index 0d7b237a6..052266a30 100644 --- a/codegen.cjs +++ b/codegen.cjs @@ -133,14 +133,8 @@ const config = { './packages/web/app/src/graphql', '!./packages/web/app/pages/api/github/setup-callback.ts', ], - preset: 'gql-tag-operations-preset', + preset: 'client', plugins: [], - config: { - dedupeFragments: true, - }, - presetConfig: { - augmentedModuleName: '@urql/core', - }, }, // CLI 'packages/libraries/cli/src/sdk.ts': { @@ -162,7 +156,7 @@ const config = { // Integration tests './integration-tests/testkit/gql/': { documents: './integration-tests/(testkit|tests)/**/*.ts', - preset: 'client-preset', + preset: 'client', plugins: [], }, }, diff --git a/integration-tests/testkit/flow.ts b/integration-tests/testkit/flow.ts index e83f5a70c..beea6bd3b 100644 --- a/integration-tests/testkit/flow.ts +++ b/integration-tests/testkit/flow.ts @@ -39,7 +39,7 @@ export function waitFor(ms: number) { export function createOrganization(input: CreateOrganizationInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation createOrganization($input: CreateOrganizationInput!) { createOrganization(input: $input) { ok { @@ -75,7 +75,7 @@ export function createOrganization(input: CreateOrganizationInput, authToken: st export function getOrganization(organizationId: string, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query getOrganization($organizationId: ID!) { organization(selector: { organization: $organizationId }) { organization { @@ -104,7 +104,7 @@ export function getOrganization(organizationId: string, authToken: string) { export function inviteToOrganization(input: InviteToOrganizationByEmailInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation inviteToOrganization($input: InviteToOrganizationByEmailInput!) { inviteToOrganizationByEmail(input: $input) { ok { @@ -129,7 +129,7 @@ export function inviteToOrganization(input: InviteToOrganizationByEmailInput, au export function renameOrganization(input: UpdateOrganizationNameInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateOrganizationName($input: UpdateOrganizationNameInput!) { updateOrganizationName(input: $input) { ok { @@ -159,7 +159,7 @@ export function renameOrganization(input: UpdateOrganizationNameInput, authToken export function joinOrganization(code: string, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation joinOrganization($code: String!) { joinOrganization(code: $code) { __typename @@ -191,7 +191,7 @@ export function joinOrganization(code: string, authToken: string) { export function getOrganizationMembers(selector: OrganizationSelectorInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query getOrganizationMembers($selector: OrganizationSelectorInput!) { organization(selector: $selector) { organization { @@ -222,7 +222,7 @@ export function getOrganizationTransferRequest( authToken: string, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query getOrganizationTransferRequest($selector: OrganizationTransferRequestSelector!) { organizationTransferRequest(selector: $selector) { organization { @@ -243,7 +243,7 @@ export function requestOrganizationTransfer( authToken: string, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation requestOrganizationTransfer($input: RequestOrganizationTransferInput!) { requestOrganizationTransfer(input: $input) { ok { @@ -268,7 +268,7 @@ export function answerOrganizationTransferRequest( authToken: string, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation answerOrganizationTransferRequest($input: AnswerOrganizationTransferRequestInput!) { answerOrganizationTransferRequest(input: $input) { ok { @@ -289,7 +289,7 @@ export function answerOrganizationTransferRequest( export function createProject(input: CreateProjectInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation createProject($input: CreateProjectInput!) { createProject(input: $input) { ok { @@ -315,7 +315,7 @@ export function createProject(input: CreateProjectInput, authToken: string) { export function renameProject(input: UpdateProjectNameInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateProjectName($input: UpdateProjectNameInput!) { updateProjectName(input: $input) { ok { @@ -344,7 +344,7 @@ export function renameProject(input: UpdateProjectNameInput, authToken: string) export function updateRegistryModel(input: UpdateProjectRegistryModelInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateRegistryModel($input: UpdateProjectRegistryModelInput!) { updateProjectRegistryModel(input: $input) { ok { @@ -367,7 +367,7 @@ export function updateRegistryModel(input: UpdateProjectRegistryModelInput, auth export function createTarget(input: CreateTargetInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation createTarget($input: CreateTargetInput!) { createTarget(input: $input) { ok { @@ -391,7 +391,7 @@ export function createTarget(input: CreateTargetInput, authToken: string) { export function renameTarget(input: UpdateTargetNameInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateTargetName($input: UpdateTargetNameInput!) { updateTargetName(input: $input) { ok { @@ -421,7 +421,7 @@ export function renameTarget(input: UpdateTargetNameInput, authToken: string) { export function createToken(input: CreateTokenInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation createToken($input: CreateTokenInput!) { createToken(input: $input) { ok { @@ -442,7 +442,7 @@ export function createToken(input: CreateTokenInput, authToken: string) { export function deleteTokens(input: DeleteTokensInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation deleteTokens($input: DeleteTokensInput!) { deleteTokens(input: $input) { deletedTokens @@ -458,7 +458,7 @@ export function deleteTokens(input: DeleteTokensInput, authToken: string) { export function readTokenInfo(token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query readTokenInfo { tokenInfo { __typename @@ -494,7 +494,7 @@ export function readTokenInfo(token: string) { export function updateMemberAccess(input: OrganizationMemberAccessInput, authToken: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateOrganizationMemberAccess($input: OrganizationMemberAccessInput!) { updateOrganizationMemberAccess(input: $input) { organization { @@ -527,7 +527,7 @@ export function publishSchema( authHeader?: 'x-api-token' | 'authorization', ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation schemaPublish($input: SchemaPublishInput!) { schemaPublish(input: $input) { __typename @@ -574,7 +574,7 @@ export function publishSchema( export function checkSchema(input: SchemaCheckInput, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation schemaCheck($input: SchemaCheckInput!) { schemaCheck(input: $input) { ... on SchemaCheckSuccess { @@ -621,7 +621,7 @@ export function deleteSchema( authHeader?: 'x-api-token' | 'authorization', ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation schemaDelete($input: SchemaDeleteInput!) { schemaDelete(input: $input) { __typename @@ -647,7 +647,7 @@ export function setTargetValidation( }, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation setTargetValidation($input: SetTargetValidationInput!) { setTargetValidation(input: $input) { enabled @@ -675,7 +675,7 @@ export function updateTargetValidationSettings( }, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateTargetValidationSettings($input: UpdateTargetValidationSettingsInput!) { updateTargetValidationSettings(input: $input) { ok { @@ -709,7 +709,7 @@ export function updateTargetValidationSettings( export function updateBaseSchema(input: UpdateBaseSchemaInput, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateBaseSchema($input: UpdateBaseSchemaInput!) { updateBaseSchema(input: $input) { __typename @@ -725,7 +725,7 @@ export function updateBaseSchema(input: UpdateBaseSchemaInput, token: string) { export function readOperationsStats(input: OperationsStatsSelectorInput, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query readOperationsStats($input: OperationsStatsSelectorInput!) { operationsStats(selector: $input) { totalOperations @@ -757,7 +757,7 @@ export function readOperationsStats(input: OperationsStatsSelectorInput, token: export function readOperationBody(selector: OperationBodyByHashInput, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query readOperationBody($selector: OperationBodyByHashInput!) { operationBodyByHash(selector: $selector) } @@ -771,7 +771,7 @@ export function readOperationBody(selector: OperationBodyByHashInput, token: str export function fetchLatestSchema(token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query latestVersion { latestVersion { baseSchema @@ -809,7 +809,7 @@ export function fetchLatestSchema(token: string) { export function fetchLatestValidSchema(token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query latestValidVersion { latestValidVersion { id @@ -850,7 +850,7 @@ export function fetchLatestValidSchema(token: string) { export function fetchVersions(selector: SchemaVersionsInput, limit: number, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query schemaVersions($limit: Int!, $selector: SchemaVersionsInput!) { schemaVersions(selector: $selector, limit: $limit) { nodes { @@ -898,7 +898,7 @@ export function fetchVersions(selector: SchemaVersionsInput, limit: number, toke export function publishPersistedOperations(input: PublishPersistedOperationInput[], token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation publishPersistedOperations($input: [PublishPersistedOperationInput!]!) { publishPersistedOperations(input: $input) { summary { @@ -924,7 +924,7 @@ export function publishPersistedOperations(input: PublishPersistedOperationInput export function updateSchemaVersionStatus(input: SchemaVersionUpdateInput, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateSchemaVersionStatus($input: SchemaVersionUpdateInput!) { updateSchemaVersionStatus(input: $input) { id @@ -953,7 +953,7 @@ export function updateSchemaVersionStatus(input: SchemaVersionUpdateInput, token export function createCdnAccess(selector: TargetSelectorInput, token: string) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation createCdnAccessToken($input: CreateCdnAccessTokenInput!) { createCdnAccessToken(input: $input) { ok { @@ -1041,7 +1041,7 @@ export async function updateOrgRateLimit( authToken: string, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation updateOrgRateLimit( $selector: OrganizationSelectorInput! $monthlyLimits: RateLimitInput! @@ -1064,7 +1064,7 @@ export async function enableExternalSchemaComposition( token: string, ) { return execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` mutation enableExternalSchemaComposition($input: EnableExternalSchemaCompositionInput!) { enableExternalSchemaComposition(input: $input) { ok { diff --git a/integration-tests/testkit/seed.ts b/integration-tests/testkit/seed.ts index d36446b60..af023fd9d 100644 --- a/integration-tests/testkit/seed.ts +++ b/integration-tests/testkit/seed.ts @@ -53,7 +53,7 @@ export function initSeed() { ownerToken, async createPersonalProject(projectType: ProjectType) { const orgs = await execute({ - document: graphql(/* GraphQL */ ` + document: graphql(` query myOrganizations { organizations { total diff --git a/integration-tests/tests/api/artifacts-cdn.spec.ts b/integration-tests/tests/api/artifacts-cdn.spec.ts index 11fe218d1..d82ee8984 100644 --- a/integration-tests/tests/api/artifacts-cdn.spec.ts +++ b/integration-tests/tests/api/artifacts-cdn.spec.ts @@ -446,7 +446,7 @@ runArtifactsCDNTests('API Mirror', { service: 'server', port: 8082, path: '/arti // runArtifactsCDNTests('Local CDN Mock', 'http://127.0.0.1:3004/artifacts/v1/'); describe('CDN token', () => { - const TargetCDNAccessTokensQuery = graphql(/* GraphQL */ ` + const TargetCDNAccessTokensQuery = graphql(` query TargetCDNAccessTokens($selector: TargetSelectorInput!, $after: String, $first: Int = 2) { target(selector: $selector) { cdnAccessTokens(first: $first, after: $after) { @@ -468,7 +468,7 @@ describe('CDN token', () => { } `); - const DeleteCDNAccessTokenMutation = graphql(/* GraphQL */ ` + const DeleteCDNAccessTokenMutation = graphql(` mutation DeleteCDNAccessToken($input: DeleteCdnAccessTokenInput!) { deleteCdnAccessToken(input: $input) { error { diff --git a/integration-tests/tests/api/oidc-integrations/crud.spec.ts b/integration-tests/tests/api/oidc-integrations/crud.spec.ts index d3389f1e1..f26864cb7 100644 --- a/integration-tests/tests/api/oidc-integrations/crud.spec.ts +++ b/integration-tests/tests/api/oidc-integrations/crud.spec.ts @@ -2,7 +2,7 @@ import { graphql } from '../../../testkit/gql'; import { execute } from '../../../testkit/graphql'; import { initSeed } from '../../../testkit/seed'; -const OrganizationWithOIDCIntegration = graphql(/* GraphQL */ ` +const OrganizationWithOIDCIntegration = graphql(` query OrganizationWithOIDCIntegration($organizationId: ID!) { organization(selector: { organization: $organizationId }) { organization { @@ -15,7 +15,7 @@ const OrganizationWithOIDCIntegration = graphql(/* GraphQL */ ` } `); -const CreateOIDCIntegrationMutation = graphql(/* GraphQL */ ` +const CreateOIDCIntegrationMutation = graphql(` mutation CreateOIDCIntegrationMutation($input: CreateOIDCIntegrationInput!) { createOIDCIntegration(input: $input) { ok { @@ -393,7 +393,7 @@ describe('create', () => { }); }); -const DeleteOIDCIntegrationMutation = graphql(/* GraphQL */ ` +const DeleteOIDCIntegrationMutation = graphql(` mutation DeleteOIDCIntegrationMutation($input: DeleteOIDCIntegrationInput!) { deleteOIDCIntegration(input: $input) { ok { @@ -560,7 +560,7 @@ describe('delete', () => { const oidcIntegrationId = createResult.createOIDCIntegration.ok!.createdOIDCIntegration.id; - const MeQuery = graphql(/* GraphQL */ ` + const MeQuery = graphql(` query Me { me { id @@ -619,7 +619,7 @@ describe('delete', () => { }); }); -const UpdateOIDCIntegrationMutation = graphql(/* GraphQL */ ` +const UpdateOIDCIntegrationMutation = graphql(` mutation UpdateOIDCIntegrationMutation($input: UpdateOIDCIntegrationInput!) { updateOIDCIntegration(input: $input) { ok { diff --git a/package.json b/package.json index 0c361c4df..b42084449 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "@graphql-codegen/add": "4.0.1", "@graphql-codegen/cli": "3.2.1", "@graphql-codegen/client-preset": "2.1.0", - "@graphql-codegen/gql-tag-operations-preset": "2.1.0", "@graphql-codegen/graphql-modules-preset": "3.1.0", "@graphql-codegen/typed-document-node": "3.0.1", "@graphql-codegen/typescript": "3.0.1", diff --git a/packages/web/app/pages/[orgId]/[projectId]/[targetId]/explorer.tsx b/packages/web/app/pages/[orgId]/[projectId]/[targetId]/explorer.tsx index 1ba6d4d9b..9fd43c86e 100644 --- a/packages/web/app/pages/[orgId]/[projectId]/[targetId]/explorer.tsx +++ b/packages/web/app/pages/[orgId]/[projectId]/[targetId]/explorer.tsx @@ -1,5 +1,5 @@ import { ReactElement } from 'react'; -import { gql, useQuery } from 'urql'; +import { useQuery } from 'urql'; import { authenticated } from '@/components/authenticated-container'; import { TargetLayout } from '@/components/layouts'; import { SchemaExplorerFilter } from '@/components/target/explorer/filter'; @@ -9,10 +9,10 @@ import { useSchemaExplorerContext, } from '@/components/target/explorer/provider'; import { DataWrapper, noSchema, Title } from '@/components/v2'; -import { OrganizationFieldsFragment, ProjectFieldsFragment, TargetFieldsFragment } from '@/graphql'; +import { graphql } from '@/gql'; import { withSessionProtection } from '@/lib/supertokens/guard'; -const SchemaView_SchemaExplorer = gql(/* GraphQL */ ` +const SchemaView_SchemaExplorer = graphql(` query SchemaView_SchemaExplorer( $organization: ID! $project: ID! @@ -48,21 +48,21 @@ const SchemaView_SchemaExplorer = gql(/* GraphQL */ ` `); function SchemaView({ - organization, - project, - target, + organizationCleanId, + projectCleanId, + targetCleanId, }: { - organization: OrganizationFieldsFragment; - project: ProjectFieldsFragment; - target: TargetFieldsFragment; + organizationCleanId: string; + projectCleanId: string; + targetCleanId: string; }): ReactElement | null { const { period } = useSchemaExplorerContext(); const [query] = useQuery({ query: SchemaView_SchemaExplorer, variables: { - organization: organization.cleanId, - project: project.cleanId, - target: target.cleanId, + organization: organizationCleanId, + project: projectCleanId, + target: targetCleanId, period, }, requestPolicy: 'cache-first', @@ -85,9 +85,9 @@ function SchemaView({
- Data collected based on operation executed against your GraphQL schema. -
-+ Data collected based on operation executed against your GraphQL schema. +
+ {hasCollectedOperations ? ( +@@ -272,11 +286,30 @@ const Page = ({ ); }; +const ProjectSettingsPageQuery = graphql(` + query ProjectSettingsPageQuery($organizationId: ID!, $projectId: ID!) { + organization(selector: { organization: $organizationId }) { + organization { + ...SettingsPage_OrganizationFragment + ...ProjectLayout_OrganizationFragment + } + } + project(selector: { organization: $organizationId, project: $projectId }) { + ...ProjectLayout_ProjectFragment + ...SettingsPage_ProjectFragment + } + } +`); + function SettingsPage(): ReactElement { return ( <>
+ Pro plan requires to defined quota of reported operations. +
++ Pick a volume a little higher than you think you'll need to avoid being rate + limited. +
++ Don't worry, you can always adjust it later. +
+- Pro plan requires to defined quota of reported operations. -
-- Pick a volume a little higher than you think you'll need to avoid being rate - limited. -
-- Don't worry, you can always adjust it later. -
-| - {edge.node.firstCharacters + - new Array(10).fill('•').join('') + - edge.node.lastCharacters} - | -{edge.node.alias} | -
- created |
- - - | -
| + {node.firstCharacters + new Array(10).fill('•').join('') + node.lastCharacters} + | +{node.alias} | +
+ created |
+ + + | +