Relay client for existing working graphQL server?

I have working tinySQL GraphQL server running at 127.0.0.1:3000. I would like to create any working Relay client for it. I mean any working example for query:

{
  groupBy (age: 20, job: "student") {
    id,
    name,
    age,
    job
  }
}

that will output in React component something like that:

{
  "data": {
    "groupBy": [
      {
        "id": 1,
        "name": "Marie",
        "age": 20,
        "job": "student"
      },
      {
        "id": 5,
        "name": "Jessie",
        "age": 20,
        "job": "student"
      }
    ]
  }
} 

Most important thing is I want to be able to set GraphQL host IP and port and also don't want to change anything in GraphQL server code. Is it possible to do it? Is it possible to do it without babelRelayPlugin.js, babel-relay-plugin, webpack, webpack-dev-server or any other magic tricks?

EDIT:

I mean:

class App extends React.Component {
  render() {
    return (
      <div>
      // Simple example here?
      </div>
    );
  }
}

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('http://127.0.0.1:3000')
);

const AppContainer = Relay.createContainer(App, {
  // Simple example here?
});

ReactDOM.render(
  // Simple example here?
);

Anyone? Is it possible to do it like this?

Upvotes: 0

Views: 289

Answers (1)

helfer
helfer

Reputation: 7172

As far as I know that is not possible with Relay. You not only need to use Relay's babel plugins, but your server also has to match the Relay GraphQL spec.

However, there are alternatives to Relay that require much less boilerplate, such as Apollo Client or Lokka. If you're looking for good React integration, then Apollo Client is probably the right choice for what you describe.

Full disclosure: I am a contributor to Apollo Client

Upvotes: 1

Related Questions