The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Accept [BREAKING_CHANGE] titles and stop flagging feature flag removals in the API breaking change check (#27859)
Félix Malfait048d6a635825
diff --git a/.github/workflows/ci-breaking-changes.yaml b/.github/workflows/ci-breaking-changes.yamlindex eb2073c6bbc..b06a5694b5c 100644--- a/.github/workflows/ci-breaking-changes.yaml+++ b/.github/workflows/ci-breaking-changes.yaml@@ -27,6 +27,7 @@ jobs:packages/twenty-emails/**packages/twenty-shared/**.github/workflows/ci-breaking-changes.yaml+ packages/twenty-utils/graphql-breaking-change-rules.cjsapi-breaking-changes:needs: changed-files-check@@ -251,6 +252,7 @@ jobs:# Both servers must be introspected with the same query, and checking# out main would otherwise swap in main's copy of itcp packages/twenty-utils/graphql-introspection-query.graphql /tmp/graphql-introspection-query.graphql+ cp packages/twenty-utils/graphql-breaking-change-rules.cjs /tmp/graphql-breaking-change-rules.cjsecho "Preserved current branch files for later restoration"@@ -466,46 +468,58 @@ jobs:if: steps.validate-schemas.outputs.valid == 'true'run: |echo "=== INSTALLING GRAPHQL INSPECTOR CLI ==="- npm install -g @graphql-inspector/cli+ npm install -g @graphql-inspector/[email protected]++ # Removing a field or enum value that was deprecated first is the+ # intended path, so it is reported as dangerous instead of breaking+ inspect_schema_diff() {+ graphql-inspector diff "$1" "$2" \+ --rule suppressRemovalOfDeprecatedField \+ --rule /tmp/graphql-breaking-change-rules.cjs+ }echo "=== GENERATING GRAPHQL DIFF REPORTS ==="- # Check if GraphQL schema has changes- echo "Checking GraphQL schema for changes..."- if graphql-inspector diff main-schema-introspection.json current-schema-introspection.json >/dev/null 2>&1; then- echo "✅ No changes in GraphQL schema"+ echo "Checking GraphQL schema for breaking changes..."+ if inspect_schema_diff main-schema-introspection.json current-schema-introspection.json > graphql-schema-diff.log 2>&1; then+ echo "✅ No breaking changes in GraphQL schema"+ elif ! grep -qE 'Detected [0-9]+ breaking change' graphql-schema-diff.log; then+ cat graphql-schema-diff.log+ echo "::error::graphql-inspector could not compare the GraphQL schema"+ exit 1else- echo "⚠️ Changes detected in GraphQL schema, generating report..."+ echo "⚠️ Breaking changes detected in GraphQL schema, generating report..."echo "core_breaking=true" >> $GITHUB_OUTPUT- echo "# GraphQL Schema Changes" > graphql-schema-diff.md- echo "" >> graphql-schema-diff.md- graphql-inspector diff main-schema-introspection.json current-schema-introspection.json >> graphql-schema-diff.md 2>&1 || {- echo "⚠️ **Breaking changes or errors detected in GraphQL schema**" >> graphql-schema-diff.md- echo "" >> graphql-schema-diff.md- echo "\`\`\`" >> graphql-schema-diff.md- graphql-inspector diff main-schema-introspection.json current-schema-introspection.json 2>&1 >> graphql-schema-diff.md || echo "Error generating diff" >> graphql-schema-diff.md- echo "\`\`\`" >> graphql-schema-diff.md- }+ {+ echo "# GraphQL Schema Changes"+ echo ""+ echo "\`\`\`"+ cat graphql-schema-diff.log+ echo "\`\`\`"+ } > graphql-schema-diff.mdfi- # Check if GraphQL metadata schema has changes- echo "Checking GraphQL metadata schema for changes..."- if graphql-inspector diff main-metadata-schema-introspection.json current-metadata-schema-introspection.json >/dev/null 2>&1; then- echo "✅ No changes in GraphQL metadata schema"+ echo "Checking GraphQL metadata schema for breaking changes..."+ if inspect_schema_diff main-metadata-schema-introspection.json current-metadata-schema-introspection.json > graphql-metadata-diff.log 2>&1; then+ echo "✅ No breaking changes in GraphQL metadata schema"+ elif ! grep -qE 'Detected [0-9]+ breaking change' graphql-metadata-diff.log; then+ cat graphql-metadata-diff.log+ echo "::error::graphql-inspector could not compare the GraphQL metadata schema"+ exit 1else- echo "⚠️ Changes detected in GraphQL metadata schema, generating report..."+ echo "⚠️ Breaking changes detected in GraphQL metadata schema, generating report..."echo "metadata_breaking=true" >> $GITHUB_OUTPUT- echo "# GraphQL Metadata Schema Changes" > graphql-metadata-diff.md- echo "" >> graphql-metadata-diff.md- graphql-inspector diff main-metadata-schema-introspection.json current-metadata-schema-introspection.json >> graphql-metadata-diff.md 2>&1 || {- echo "⚠️ **Breaking changes or errors detected in GraphQL metadata schema**" >> graphql-metadata-diff.md- echo "" >> graphql-metadata-diff.md- echo "\`\`\`" >> graphql-metadata-diff.md- graphql-inspector diff main-metadata-schema-introspection.json current-metadata-schema-introspection.json 2>&1 >> graphql-metadata-diff.md || echo "Error generating diff" >> graphql-metadata-diff.md- echo "\`\`\`" >> graphql-metadata-diff.md- }+ {+ echo "# GraphQL Metadata Schema Changes"+ echo ""+ echo "\`\`\`"+ cat graphql-metadata-diff.log+ echo "\`\`\`"+ } > graphql-metadata-diff.mdfi+ cat graphql-schema-diff.log graphql-metadata-diff.log+# Show summaryecho "Generated diff files:"ls -la *-diff.md 2>/dev/null || echo "No diff files generated (no changes detected)"@@ -653,6 +667,8 @@ jobs:- name: Fail on breaking changesif: steps.validate-schemas.outputs.valid == 'true'+ env:+ PR_TITLE: ${{ github.event.pull_request.title }}run: |breaking=false@@ -716,8 +732,13 @@ jobs:if [ "$breaking" = "true" ]; thenecho ""+ if echo "$PR_TITLE" | grep -qiE '\[breaking[ _-]?change\]'; then+ echo "::warning::Breaking API changes accepted: the PR title is tagged [BREAKING_CHANGE]."+ exit 0+ fiecho "This PR introduces breaking changes to the public API."- echo "If intentional, deprecate the old endpoint and introduce a new one."+ echo "If intentional, deprecate the old endpoint and introduce a new one,"+ echo "or tag the PR title with [BREAKING_CHANGE] to accept them."echo "See the breaking changes report artifact and PR comment for details."exit 1fidiff --git a/packages/twenty-utils/graphql-breaking-change-rules.cjs b/packages/twenty-utils/graphql-breaking-change-rules.cjsnew file mode 100644index 00000000000..4c366b6a279--- /dev/null+++ b/packages/twenty-utils/graphql-breaking-change-rules.cjs@@ -0,0 +1,24 @@+// graphql-inspector diff rule used by ci-breaking-changes.yaml.+// Feature flag keys come and go as features ship, and API consumers never+// send or match on them, so dropping one is reported but does not fail CI.+const ENUMS_WITH_REMOVABLE_VALUES = ['FeatureFlagKey'];++const isRemovableEnumValue = (change) => {+ if (change.type !== 'ENUM_VALUE_REMOVED' || typeof change.path !== 'string') {+ return false;+ }++ const [enumName] = change.path.split('.');++ return ENUMS_WITH_REMOVABLE_VALUES.includes(enumName);+};++module.exports = ({ changes }) =>+ changes.map((change) =>+ change.criticality.level === 'BREAKING' && isRemovableEnumValue(change)+ ? {+ ...change,+ criticality: { ...change.criticality, level: 'DANGEROUS' },+ }+ : change,+ );