Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
38cf809
Add operation-location-migration
eddeee888 Jul 21, 2025
509ce6d
Set up basic preset structure
eddeee888 Jul 21, 2025
61d55eb
Set up base e2e
eddeee888 Jul 21, 2025
2958a27
Set up base e2e tests
eddeee888 Jul 21, 2025
35ee06c
WIP
eddeee888 Jul 21, 2025
62ebe07
Rename e2e test
eddeee888 Jul 22, 2025
9b3133e
WIP replace
eddeee888 Jul 22, 2025
2491b1e
POC
eddeee888 Jul 22, 2025
042f2d7
Remove unused generation
eddeee888 Jul 22, 2025
bb8d32a
Set up test with params
eddeee888 Jul 22, 2025
3d7170b
QOL formatting
eddeee888 Jul 23, 2025
2c53412
Update e2e test
eddeee888 Jul 23, 2025
c019e28
Ensure no double Doc
eddeee888 Jul 23, 2025
6b37abf
Add testing-utils lib
eddeee888 Jul 23, 2025
f64a720
Add test setup
eddeee888 Jul 23, 2025
803a3d5
Baseline tests
eddeee888 Jul 23, 2025
1c2e1aa
Fix import issues
eddeee888 Jul 23, 2025
b7d1a6b
Fix multiple docs being put incorrectly into graphql tag
eddeee888 Jul 23, 2025
e91fd53
Set up subscription test
eddeee888 Jul 23, 2025
d16c34e
Add TODO
eddeee888 Jul 23, 2025
d26442f
Handle dynamic config for gqlTag and hook imports
eddeee888 Jul 24, 2025
761ec77
Prepare for near-operation-file
eddeee888 Jul 24, 2025
6f4c7c1
Update test setup
eddeee888 Jul 24, 2025
9d3a608
Add test setup to testdefault comment
eddeee888 Jul 24, 2025
9eaae2b
Warn, not throw
eddeee888 Jul 24, 2025
bd6de9e
Set up CI for operation-location-migration
eddeee888 Jul 24, 2025
ae89f2b
Add package README
eddeee888 Jul 24, 2025
fe1572a
Add changeset
eddeee888 Jul 24, 2025
8a2c2de
Update package.json
eddeee888 Jul 24, 2025
ef9c0cc
Allow publishing
eddeee888 Jul 24, 2025
6888105
Update package.json publish config
eddeee888 Jul 24, 2025
963b496
Finalise
eddeee888 Jul 24, 2025
66bebfe
Update e2e README
eddeee888 Jul 25, 2025
fe12183
Test CI
eddeee888 Jul 25, 2025
de03392
Shuffle job location
eddeee888 Jul 25, 2025
7d7b09a
Fix sub-workflow for operation-location-migration
eddeee888 Jul 25, 2025
d255f49
Disable windows for now
eddeee888 Jul 25, 2025
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
5 changes: 5 additions & 0 deletions .changeset/curvy-dolls-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eddeee888/gcg-operation-location-migration': patch
---

Add base preset to migrate to co-location and Server Preset
18 changes: 16 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
outputs:
affected-typescript-resolver-files: ${{ steps.affected.outputs.typescript-resolver-files }}
affected-typescript-resolver-files-e2e: ${{ steps.affected.outputs.typescript-resolver-files-e2e }}
affected-operation-location-migration: ${{ steps.affected.outputs.operation-location-migration }}
affected-operation-location-migration-e2e: ${{ steps.affected.outputs.operation-location-migration-e2e }}
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand All @@ -37,14 +39,26 @@ jobs:
run: |
echo "typescript-resolver-files=$(./tools/ci/bin/check-affected.sh lib typescript-resolver-files origin/master)" >> $GITHUB_OUTPUT
echo "typescript-resolver-files-e2e=$(./tools/ci/bin/check-affected.sh lib typescript-resolver-files-e2e origin/master)" >> $GITHUB_OUTPUT
echo "operation-location-migration=$(./tools/ci/bin/check-affected.sh lib operation-location-migration origin/master)" >> $GITHUB_OUTPUT
echo "operation-location-migration-e2e=$(./tools/ci/bin/check-affected.sh lib operation-location-migration-e2e origin/master)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT

typescript-resolver-files:
needs: precheck
if: ${{ needs.precheck.outputs.affected-typescript-resolver-files == 'true' }}
uses: ./.github/workflows/typescript-resolver-files.yml
uses: ./.github/workflows/projects/typescript-resolver-files.yml

typescript-resolver-files-e2e:
needs: precheck
if: ${{ needs.precheck.outputs.affected-typescript-resolver-files == 'true' || needs.precheck.outputs.affected-typescript-resolver-files-e2e == 'true' }}
uses: ./.github/workflows/typescript-resolver-files-e2e.yml
uses: ./.github/workflows/projects/typescript-resolver-files-e2e.yml

operation-location-migration:
needs: precheck
if: ${{ needs.precheck.outputs.affected-operation-location-migration == 'true' }}
uses: ./.github/workflows/projects/operation-location-migration.yml

operation-location-migration-e2e:
needs: precheck
if: ${{ needs.precheck.outputs.affected-operation-location-migration == 'true' || needs.precheck.outputs.affected-operation-location-migration-e2e == 'true' }}
uses: ./.github/workflows/projects/operation-location-migration-e2e.yml
34 changes: 34 additions & 0 deletions .github/workflows/projects/operation-location-migration-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
workflow_call:

env:
node-version: '22.x'

jobs:
operation-location-migration-e2e:
strategy:
matrix:
os: [ubuntu-22.04] # TODO: test with windows
node-version: [18.x, 20.x, 22.x]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
cache-dependency-path: '**/yarn.lock'

- name: Install deps
run: yarn install --prefer-offline

- name: e2e
run: yarn nx e2e operation-location-migration-e2e
35 changes: 35 additions & 0 deletions .github/workflows/projects/operation-location-migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
workflow_call:

env:
node-version: '22.x'

jobs:
operation-location-migration:
strategy:
matrix:
os: [ubuntu-22.04, windows-latest]
node-version: [18.x, 20.x, 22.x]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
cache-dependency-path: '**/yarn.lock'

- name: Install deps
run: yarn install --prefer-offline

- name: Lint
run: yarn nx lint operation-location-migration

- name: Test
run: yarn nx test operation-location-migration

- name: Build
run: yarn nx build operation-location-migration
15 changes: 14 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"{projectRoot}/package.json"
]
}
},
"@nx/js:swc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
},
"namedInputs": {
Expand All @@ -57,5 +62,13 @@
"workspaceLayout": {
"appsDir": "packages",
"libsDir": "packages"
}
},
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "eslint:lint"
}
}
]
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"@eslint/eslintrc": "3.3.1",
"@graphql-codegen/add": "5.0.3",
"@graphql-codegen/cli": "5.0.4",
"@graphql-codegen/near-operation-file-preset": "3.1.0",
"@graphql-codegen/plugin-helpers": "5.1.0",
"@graphql-codegen/schema-ast": "4.1.0",
"@graphql-codegen/typescript": "4.1.3",
"@graphql-codegen/typescript-react-apollo": "4.3.3",
"@graphql-codegen/typescript-resolvers": "4.4.2",
"@graphql-tools/merge": "9.0.4",
"@nx/devkit": "21.3.1",
Expand All @@ -30,8 +32,10 @@
"@nx/plugin": "21.3.1",
"@nx/workspace": "21.3.1",
"@swc-node/register": "1.9.2",
"@swc/cli": "~0.6.0",
"@swc/core": "1.5.7",
"@swc/helpers": "0.5.12",
"@swc/jest": "~0.2.38",
"@types/jest": "30.0.0",
"@types/micromatch": "4.0.6",
"@types/node": "22.0.3",
Expand All @@ -50,6 +54,7 @@
"ts-jest": "29.1.0",
"ts-morph": "22.0.0",
"ts-node": "10.9.1",
"tsx": "4.20.3",
"typescript": "5.8.3",
"typescript-eslint": "8.37.0"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/operation-location-migration-e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# operation-location-migration-e2e

```bash
nx e2e operation-location-migration-e2e
```
3 changes: 3 additions & 0 deletions packages/operation-location-migration-e2e/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import baseConfig from '../../eslint.config.mjs';

export default [...baseConfig];
66 changes: 66 additions & 0 deletions packages/operation-location-migration-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "operation-location-migration-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/operation-location-migration-e2e/src",
"projectType": "library",
"implicitDependencies": ["operation-location-migration"],
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": [
"nx test-setup operation-location-migration-e2e -c test-index-to-colocation",
"nx graphql-codegen operation-location-migration-e2e --verbose -c test-index-to-colocation",
"nx test-setup operation-location-migration-e2e -c test-near-operation-file-to-colocation",
"nx graphql-codegen operation-location-migration-e2e --verbose -c test-near-operation-file-to-colocation",
"OUTPUT_PATTERN=\"{projectRoot}/src/**/*.ts\" bash packages/testing-utils/bin/assert-e2e.sh"
],
"parallel": false
}
},
"test-setup": {
"executor": "nx:run-commands",
"options": {},
"configurations": {
"test-index-to-colocation": {
"commands": [
"tsx --tsconfig={projectRoot}/tsconfig.json {projectRoot}/src/test-index-to-colocation/testSetup.ts"
]
},
"test-near-operation-file-to-colocation": {
"commands": [
"tsx --tsconfig={projectRoot}/tsconfig.json {projectRoot}/src/test-near-operation-file-to-colocation/testSetup.ts"
]
}
}
},
"graphql-codegen": {
"executor": "@eddeee888/nx-graphql-code-generator:codegen",
"options": {},
"configurations": {
"test-index-to-colocation": {
"configFile": "{projectRoot}/src/test-index-to-colocation/codegen.mts"
},
"test-near-operation-file-to-colocation": {
"configFile": "{projectRoot}/src/test-near-operation-file-to-colocation/codegen.mts"
}
},
"dependsOn": ["prepare-e2e-modules"]
},
"prepare-e2e-modules": {
"executor": "nx:run-commands",
"options": {
"commands": [
"rimraf node_modules/@eddeee888/gcg-operation-location-migration",
"cp -r dist/packages/operation-location-migration node_modules/@eddeee888/gcg-operation-location-migration"
],
"parallel": false
},
"dependsOn": ["^build"]
},
"lint": {
"executor": "@nx/eslint:lint"
}
},
"tags": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { CodegenConfig } from '@graphql-codegen/cli';
import { defineConfig } from '@eddeee888/gcg-operation-location-migration';

const config: CodegenConfig = {
schema: [
'packages/operation-location-migration-e2e/src/test-index-to-colocation/**/*.graphqls',
],
hooks: {
afterAllFileWrite: ['prettier --write'],
},
generates: {
'packages/operation-location-migration-e2e/src/test-index-to-colocation/generated/hooks.generated.ts':
{
documents: [
'packages/operation-location-migration-e2e/src/test-index-to-colocation/operations/*.graphql',
],
plugins: [
'typescript',
'typescript-operations',
'typescript-react-apollo',
],
},
'packages/operation-location-migration-e2e/src/test-index-to-colocation':
defineConfig(
{
tsConfigFilePath:
'packages/operation-location-migration-e2e/src/test-index-to-colocation/tsconfig.json',
gqlTag: {
name: 'graphql',
importFrom: './gql',
importType: 'relative',
},
hooksImportFrom: '@apollo/client/react',
},
{
documents:
'packages/operation-location-migration-e2e/src/test-index-to-colocation/operations/*.graphql',
}
),
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* This file has been created on filesystem by @workspace/testing-utils#createTestSetup */
import { useLazyQuery } from '@apollo/client/react';
import { graphql } from '../gql';

const MeDoc = graphql(`
query Me {
me {
__typename
}
}
`);

export const MeComponent = () => {
useLazyQuery(MeDoc);
return 'Me';
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* This file has been created on filesystem by @workspace/testing-utils#createTestSetup */
import { useQuery } from '@apollo/client/react';
import { graphql } from '../gql';

const MeDoc = graphql(`
query Me {
me {
__typename
}
}
`);

export const MeComponent = () => {
useQuery(MeDoc, { skip: true });
return 'Me';
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* This file has been created on filesystem by @workspace/testing-utils#createTestSetup */
import { useSuspenseQuery } from '@apollo/client/react';
import { graphql } from '../gql';

const MeDoc = graphql(`
query Me {
me {
__typename
}
}
`);

export const MeComponent = () => {
useSuspenseQuery(MeDoc);
return 'Me';
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* This file has been created on filesystem by @workspace/testing-utils#createTestSetup */

import { useMeLazyQuery } from '../generated/hooks.generated';
import { useQuery, useSuspenseQuery, useMutation } from '@apollo/client/react';
import { graphql } from '../gql';

const UpdateUserDoc = graphql(`
mutation UpdateUser($input: UpdateUserInput!) {
updateUser(input: $input) {
id
name
}
}
`);

const MeDoc = graphql(`
query Me {
me {
__typename
}
}
`);

export const UserComponent = () => {
useQuery(MeDoc, { onCompleted: () => {} });
const res = useSuspenseQuery(MeDoc);
useMutation(UpdateUserDoc);
return 'User';
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* This file has been created on filesystem by @workspace/testing-utils#createTestSetup */
import { useSubscription } from '@apollo/client/react';
import { graphql } from '../gql';

const UserChangesDoc = graphql(`
subscription UserChanges {
userChanges(id: "10") {
id
name
}
}
`);

export const UserSubscription = () => {
useSubscription(UserChangesDoc, {});
};
Loading