-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Comments
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. |
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", |
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:
At one point, the packager seemed to get stuck on resolving dependencies, what fixed this was:
|
@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? |
@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. |
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. |
@helfer when I tried (as of apollo-client@0.1.6) I got something like 'inline fragments not yet supported'. |
I thought we supported fragments but it turns out we don't everywhere! Going to fix that ASAP! |
thx @stubailo, going to wait for it. (and closed the issue by mistake) |
…nce-1 Remove reference to future subscriptions feature
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?
The text was updated successfully, but these errors were encountered: