Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline fragments not supported everywhere #147

Closed
deoqc opened this issue Apr 25, 2016 · 10 comments
Closed

Inline fragments not supported everywhere #147

deoqc opened this issue Apr 25, 2016 · 10 comments
Assignees
Labels
Milestone

Comments

@deoqc
Copy link

deoqc commented Apr 25, 2016

I already have GraphQL server (w/ express), and I am currently using Relay to connect it (also already have a Redux store, for client state). 'Cause Relay is too complex/hard-to-be-confident, I followed the path to integrate my Redux store to Apollo Client, but my app crashes with the following:

$export is not a function. (In '$export($export.S + $export.F * !require(1245 /* ./_descriptors /), 'Object', { defineProperty: require(1240 / ./_object-dp */).f })', '$export' is an instance of Object)
in file: app/node_modules/graphql/node_modules/core-js/library/modules/es6.object.define-property.js

Running on React-Native 0.23.1, GraphQL 0.5.0.

Any clues?

@stubailo
Copy link
Contributor

Hmm, could you post some of your code? Perhaps it is something specific to React Native, it's pretty hard to see what is going on from that error, though.

@stubailo stubailo self-assigned this Apr 25, 2016
@deoqc
Copy link
Author

deoqc commented Apr 25, 2016

I only connected the apollo to the store, didn't do anything else (see bellow). But the app crashes if have this code.

Maybe could be some conflict with Relay? This is the Relay example I followed to get it to work with React Native. For example, this is the .babelrc that I had to use.


Create Apollo Client (file Apollo.js):

import { ApolloClient, createNetworkInterface } from 'apollo-client';
const networkInterface = createNetworkInterface('http://localhost:8080/graphql');

export default new ApolloClient({
  networkInterface,
});

Connect to the store:

...
import apolloClient from '../Apollo';
import { combineReducers } from 'redux';

const apollo = apolloClient.reducer();

export default combineReducers({
  ...
  apollo,
});

Manually install runtime-plugin (error if don't):

"babel-plugin-transform-runtime": "6.6.0",

@stubailo stubailo assigned martijnwalraven and unassigned stubailo Apr 25, 2016
@martijnwalraven
Copy link
Contributor

martijnwalraven commented Apr 26, 2016

I was able to reproduce this error and finally managed to get it to work. I still don't fully understand the issue, but it seems it has to do with using Babel 6 with React Native's Packager (see facebook/react-native#4062).

This seems to fix it:

rm -rf node_modules
npm install
npm install babel-plugin-transform-runtime@6.6.0
npm install babel-preset-es2015@6.6.0

At one point, the packager seemed to get stuck on resolving dependencies, what fixed this was:

watchman watch-del-all
node_modules/react-native/packager/packager.sh --reset-cache

@deoqc
Copy link
Author

deoqc commented Apr 28, 2016

@martijnwalraven I had no success following your steps, but I mocked the data, removed relay and its dependencies (from babel, plugin, etc) and the started using Apollo client successfully. The problem must lie in some conflict with its babel dependency as you suggested (my initial hypothesis also).

Now the problem is that I used the Node Interface to fetch data from different types, which it doesn't seem (yet?) possible with Apollo. Like so:

const mapQueriesToProps = ({ownProps: { id }}) => ({
  data: {
    query: `
      query getSomeData($id: ID!) {
        node(id: $id) {
          id
          ... on SomeType {
            first_field
            second_field
          }
        }
      }
    `,
    variables: {
      id,
    },
    forceFetch: false,
    returnPartialData: true,
  },
});

@stubailo Is this feature in the pipeline for the short-term or should I implement a route to have a query for each different types of Node I previously had?

@helfer
Copy link
Contributor

helfer commented Apr 28, 2016

@deoqc I'm not sure how you were doing it before, but you should be able to build the equivalent of a node interface, if you use a GraphQL Union and define the resolveType.

@deoqc
Copy link
Author

deoqc commented Apr 28, 2016

@helfer doesn't GraphQL Union requires fragments the same way that Node Interface do? (reading the fb docs).

In this case, I think I can't use Union for the same reason that I can't use Interface in Apollo, due to lack of fragment support.

@helfer
Copy link
Contributor

helfer commented Apr 28, 2016

Pretty sure you can use inline fragments with apollo-client, just not named fragments. The fragment in the example above is an inline fragment. @stubailo: please correct me if I'm wrong.

@deoqc
Copy link
Author

deoqc commented Apr 28, 2016

@helfer when I tried (as of apollo-client@0.1.6) I got something like 'inline fragments not yet supported'.

@deoqc deoqc closed this as completed Apr 28, 2016
@stubailo stubailo reopened this Apr 28, 2016
@stubailo
Copy link
Contributor

I thought we supported fragments but it turns out we don't everywhere! Going to fix that ASAP!

@deoqc
Copy link
Author

deoqc commented Apr 28, 2016

thx @stubailo, going to wait for it. (and closed the issue by mistake)

@stubailo stubailo assigned stubailo and unassigned martijnwalraven Apr 28, 2016
@stubailo stubailo changed the title Migrating from Relay Inline fragments not supported everywhere Apr 28, 2016
@stubailo stubailo added this to the 5/10 cycle milestone May 2, 2016
jbaxleyiii pushed a commit that referenced this issue Oct 18, 2017
…nce-1

Remove reference to future subscriptions feature
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants