score:3
Accepted answer
How about doing it like this:
const userFragment = gql`
fragment Relationship_user on User {
...User_user
}
${User.fragments.user}
`;
Relationship.fragments = {
user1: userFragment,
user2: userFragment,
};
Apart from that, I'd recommend you scope your fragment names as shown above, as some kind of name spacing is required, because otherwise it's more likely you'll run into using the same fragment names twice.
i.e.
User.fragments.user
=>User_user
Relationship.fragments.user
=>Relationship_user
Source: stackoverflow.com
Related Query
- Fragment composition with Apollo client: convention and boilerplate
- Why query with apollo client on fragment gives me an empty object while api is working fine?
- Querying and Mutating a Form with Apollo Client GraphQL
- Trigger same query multiple times with apollo client fetchMore Apollo Client and append the data
- How to solve 'TypeError: Cannot read property 'params' of undefined' with Apollo Graphql Client and React?
- When and how to redirect with Apollo Client and React Router
- I need help understanding how I should use AWS with a GraphQL server and Apollo client
- test react component that use query and subscription with apollo client
- Apollo client access component props with hoc and TypeScript
- Relay vs Redux vs Apollo with GraphQL and React-Native
- How to do Batch Mutations with Apollo Client
- How to correctly redirect after catching authentication failure with Apollo and React
- Reset store after logout with Apollo client
- How to use Apollo Client + React Router to implement private routes and redirection based on user status?
- Is graphql's ID type necessary if I've set an unique identifier with dataIdFromObject in Apollo Client
- How to handle httpOnly cookie authentication in next.js with apollo client
- Apollo client 2 with React couldn't make query
- How to deal with different variable name convention in backend api and frontend
- How to test Websocket Client with Jest and react-testing-library
- Issue with refetchQueries in the Apollo Client useMutation hook
- Use Auth0's hook useAuth0 to get token and set header in Apollo client
- How to refresh firebase IdToken with apollo Reactjs client
- Optimistic React Apollo ui lag with React Beautiful Drag and Drop
- Dynamically set GraphQL queries for React components with Apollo Client
- With NextJS and next-routes, How to Handle 404 from server.js and also client side
- How to detect disconnect and reconnect for subscription(websocket) in apollo client
- Apollo client - local field with computed value from object
- Unable to access returned data from a refetchQueries with Apollo and GraphQL
- onCompleted handler not firing with Apollo Client Query
- What's the best way to deal with an error in the server side and in the client side using nodejs + express
More Query from same tag
- How to create React elements in an array (with props) and then render them by simply mapping over that array?
- React-router: Uncaught ReferenceError: Router is not defined
- How to import dependencies in reactjs class?
- Edit text value in React array using props and state?
- Conditionally render attributes in React / Formik
- Why is my returned response not matching the type inferred?
- How can create uniqe value in map function? Its need for key value
- react js and existing Laravel project
- Do I need to manually define onChange handlers to populate state variables?
- How to make a generic callback function react
- React - Unhandled Rejection (TypeError): Cannot read property 'city' of undefined
- Does React make a clone of your object when you use the set function?
- Flow: optional prop that uses generic types
- unit testing using enzyme: Pass react props as event to wrapper
- useCallback vs useEffect in React
- Uncaught Invariant Violation: Too many re-renders
- ReactJS select table row with bool variable
- how can i get redirected from component to another by using a button
- How to extract element from JSON array and put into another array
- How to fix this issue with Sass in my React project?
- How to read the value of propTypes of my Button component
- Cant pass array of objects to setPeople function in React
- Function or fat arrow for a React functional component?
- Why aren't my stylesheets being included in the Webpack build?
- What is difference between reactstrap and react-bootstrap?
- send file from formik reactjs to springboot using axios with saga
- Combinations of specific elements in array
- react-router not waiting for animation before changing route
- How can I convert the this cascading dropdown class component to functional one using React Hooks?
- How can I get panel to fill width of screen, responsively