question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple inline fragments - & vs |

See original GitHub issue

On a query like this

      dishes {

        ... on RecipeDish {
          id
          recipeId
        }

        ... on IngredientDish {
          id
          ingredient 
        }
      }

The result is

export type Dishes = RecipeDishInlineFragment & IngredientDishInlineFragment

But it should be

export type Dishes = RecipeDishInlineFragment | IngredientDishInlineFragment

Am I not mistaken?

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
iamdanthedevcommented, Nov 15, 2017

@altschuler I wrote the comment above being sure that union is & instead of I %)

apollo-codegen produces a union for instance, however it doesn’t generate it in a handy form this library does (with subtypes, instead of one long type), which makes it (apollo-codegen) not that useful

export type MenuDishFragmentFragment = {
  dishes:  Array<( {
      __typename: "RecipeDish",
      id: string,
      recipeId: string,
    } | {
      __typename: "IngredientDish",
      id: string,
      ingredient:  {
        productId: string,
      },
    }
  ) >,
};

1reaction
dotansimhacommented, Mar 13, 2018

ok, so I did some work on it, and the results will be: FIELDS & FRAGMENT_SPREAD & (INLINE_FRAGMENT | INLINE_FRAGMENT | INLINE_FRAGMENT). Since fragment spread are in use to specify list of fields in a context of a type, and inline fragments are in use to declare different selection set for interface/union.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fragments - Apollo GraphQL Docs
A GraphQL fragment is a piece of logic that can be shared between multiple queries and mutations. ... Every fragment includes a subset...
Read more >
How to use GraphQL fragment on multiple types
Gatsby recent release allow users to set up their own types for graphql schema, making this question finally possible.
Read more >
GraphQL - Inline Fragments - 4me Learning Center
For example a Translation can be linked to multiple record types: a service, ... An Inline Fragment has the following syntax ...on Type...
Read more >
GraphQL fragments explained - LogRocket Blog
A GraphQL fragment lets you build multiple fields, and include them ... "avatarUrl": "https://avatars1.githubusercontent.com/u/1342004?v=4", ...
Read more >
How to query your schema with GraphQL fragments
The code to define these fields has to be written multiple times, ... Inline fragments are useful for queries in which we have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found