Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
¿Usando variables estáticas en un esquema de Graphql para evitar la duplicación?

¿Es una buena práctica usar variables estáticas en un esquema de Graphql en parámetros de esquema repetidos? como se muestra en el siguiente ejemplo

 const TeaserGroupParams = `{ id: String workflowId: String headline: String description: String groupLayout: TeaserGroupLayout elementLayout: TeaserGroupElementLayout teaserElements: [TeaserElement] teaserDynamic: TeaserDynamic teaserDynamicConfigId: Int toplistSorting: String bookmarked: Boolean workingCopy: Workflow workflows: [Workflow] assignmentCount: Int assignedElements: [AssignedUnion] } `; export const TeaserGroupSchema = ` union AssignedUnion = Article | Page type TeaserGroup ${TeaserGroupParams} `; export const TeaserGroupWorkflowSchema = ` type TeaserGroupWorkflow ${TeaserGroupParams} `;

¿Puedo tener también un enfoque similar en el lado del cliente, para evitar la duplicación una vez más?

 query GetTeaserGroup ($id: String!) { teaserGroup(id: $id) { asset { ... on TeaserGroup { id headline

...

 ... on TeaserGroupWorkflow { id headline description elementLayout

...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tomado de https://www.apollographql.com/docs/react/caching/cache-configuration

 import { gql } from '@apollo/client'; export const CORE_COMMENT_FIELDS = gql` fragment CoreCommentFields on Comment { id postedBy { username displayName } createdAt content } `;

y .. :

 import { gql } from '@apollo/client'; import { CORE_COMMENT_FIELDS } from './fragments'; export const GET_POST_DETAILS = gql` ${CORE_COMMENT_FIELDS} query CommentsForPost($postId: ID!) { post(postId: $postId) { title body author comments { ...CoreCommentFields } } } `;

Fue una buena práctica, con Fragments todo funciona según lo previsto. Gracias Tomasz

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!