i18n-array-groq-query-migration

작성자: sanity-io

Detect and update legacy GROQ patterns where language is read from _key for sanity-plugin-internationalized-array when users mention v4 to v5 migration, or…

npx skills add https://github.com/sanity-io/plugins --skill i18n-array-groq-query-migration

Internationalized Array GROQ Migration

Goal

Help users find GROQ queries that still read locale from _key and rewrite them safely for v5.

When To Use

Use this skill when a user asks to:

  • migrate sanity-plugin-internationalized-array from v4 to v5
  • migrate @sanity/document-internationalization from v5 to v6 alongside sanity-plugin-internationalized-array language field changes
  • find queries that still use _key for language lookup
  • update GROQ filters like _key == "en" or _key == $language

Detection Workflow

Detection commands below use grep. If your environment differs, use your editor's global search with equivalent patterns.

  1. Search for direct language comparisons on _key:
grep -REn --exclude-dir=node_modules "_key[[:space:]]*==[[:space:]]*(\"[^\"]+\"|'[^']+'|\\$[A-Za-z_][A-Za-z0-9_]*)" .
  1. Search for any localized-array filters that mention _key:
grep -REn --exclude-dir=node_modules "\[[^]]*_key[^]]*\]" .
  1. Prioritize matches that look like localized-value reads, for example:
  • field[_key == ...][0].value
  • select(...) branches that compare _key to a language value
  1. Check for uses of groq and verify if they use _key as the language, if it is using it, update them.

  2. Explicitly check for template-interpolated language expressions and keep the same operand, for example:

    • _key == "${language}"
    • _key == "${locale}"
  3. Review each match to avoid false positives where _key is used for unrelated array item identity.

Rewrite Rules

Use the same language operand from the original query. The language operand can be a string literal (for example "en"), a variable (for example $language), or a template-interpolated expression (for example "${language}").

  • Before data migration is executed (backwards compatible):
    • _key == <languageExpr> -> language == <languageExpr> || _key == <languageExpr>
  • After migration is complete:
    • language == <languageExpr> || _key == <languageExpr> -> language == <languageExpr>

Examples

Legacy:

*[_type == "person"]{
  "greeting": greeting[_key == $language][0].value
}

Backwards compatible:

*[_type == "person"]{
  "greeting": greeting[language == $language || _key == $language][0].value
}

Post-migration final form:

*[_type == "person"]{
  "greeting": greeting[language == $language][0].value
}

Response Template

When reporting findings to a user:

  1. List each query location that still uses _key as language source.
  2. Show the exact replacement using the same language expression.
  3. Label each replacement as:
    • backwards-compatible (pre-migration), or
    • final (post-migration complete).
  4. Label each match category as runtime, docs/example, or ambiguous.
  5. Call out any ambiguous _key usage that needs manual review.

sanity-io의 다른 스킬

performance-optimization
sanity-io
애플리케이션 성능을 최적화합니다. 성능 요구사항이 있거나, 성능 회귀가 의심되거나, Core Web Vitals 또는 로드 시간이…
official
rxjs-like-a-pro
sanity-io
이 스킬은 관용적이고 조합 가능하며 일반적인 함정이 없는 RxJS 코드를 작성하는 데 도움을 줍니다. 핵심 철학: 로직을 observable 체인 안에 유지하세요. .subscribe()를 사용할 때마다 해당 작업을 .pipe() 내부의 변환으로 표현할 수 있는지 물어보세요.
official
find-skills
sanity-io
사용자가 "X를 어떻게 하죠", "X를 위한 스킬을 찾아줘", "X를 할 수 있는 스킬이 있나요..." 같은 질문을 하거나 특정 요구를 표현할 때 에이전트 스킬을 찾고 설치하도록 도와줍니다.
official
next-cache-components
sanity-io
Next.js 16 캐시 컴포넌트 - PPR, use cache 지시어, cacheLife, cacheTag, updateTag
official
vercel-react-best-practices
sanity-io
Vercel Engineering의 React 및 Next.js 성능 최적화 가이드라인입니다. 이 스킬은 React/Next.js 코드를 작성, 검토 또는 리팩토링할 때 사용해야 합니다.
official
frontend-design
sanity-io
차별화된 프로덕션 수준의 프론트엔드 인터페이스를 높은 디자인 품질로 제작합니다. 사용자가 웹 컴포넌트, 페이지 등을 구축해 달라고 요청할 때 이 스킬을 사용하세요.
official
plugin-transfer
sanity-io
에이전트가 copy-plugin 생성기 워크플로를 사용하여 기존 플러그인을 이 모노레포로 마이그레이션하도록 안내합니다.
official
test-studio-script-runner
sanity-io
dev/test-studio Script Runner 도구를 설명합니다. dev/test-studio/src/script-runner에서 스크립트를 추가, 편집, 실행 또는 문서화할 때 사용하거나...
official