aerogear / create-graphql

Command-line utility to build production-ready servers with GraphQL.
MIT License
440 stars 38 forks source link

Improve Relay generation #25

Closed sibelius closed 7 years ago

sibelius commented 7 years ago

I think we need a flag on .graphqlrc to enable some Relay generation code tweaks

for instance a Relay GraphQL Type could have a globalIdField()

Changes required on Type.js.template

import {
  globalIdField,
} from 'graphql-relay';
import {
  NodeInterface,
} from '../interface/NodeInterface';

fields: () => ({
    id: globalIdField('Company'),
    _id: {
      type: GraphQLString,
      resolve: obj => obj._id,
    },
...

interfaces: () => [NodeInterface],                                                                                 
lucasbento commented 7 years ago

An entry as relay: true would be good for this.

sibelius commented 7 years ago

maybe something like:

type: 'relay' or type: 'apollo' or type: 'raw'?

lucasbento commented 7 years ago

There is no need for type: 'raw' right now, since Apollo doesn't require any changes on server.

I thought that accepting a string may lead to errors if user provided it with a typo or something but I guess it would be better to work that way.

lucasbento commented 7 years ago

We are only working with Relay right now, I guess this can go on the template as well.

sibelius commented 7 years ago

Yep

sibelius commented 7 years ago

missing

interfaces: () => [NodeInterface],