grooviter / gql

Groovy GraphQL library
http://grooviter.github.io/gql/
Apache License 2.0
49 stars 6 forks source link

Review schema roots naming #6

Closed mariogarcia closed 7 years ago

mariogarcia commented 7 years ago

At the moment DSL.schema queries are defined like:

GraphQLSchema schema = DSL.schema {
  query('QueryRoot') {
    field('byYear') { }
    field('byActor') { }
  }
}

But I would say that if we're adding queries definitions inside one query root, it would make more sense to have defined it like:

GraphQLSchema schema = DSL.schema {
  queries('QueryRoot') {
    field('byYear') {}
    field('byActor') { }
   }
}

And given the fact that we only add one query root and one mutation root we could omit the name of the query root (and implicityly call them QueryRoot and MutationRoot)

GraphQLSchema schema = DSL.schema {
  queries {
    field('byYear') {}
    field('byActor') { }
  }
  mutations {
    field('insertMovie') { }
  }
}

or:

GraphQLSchema schema = DSL.schema {
  queries {
    addField filmGraphQL.getByYearQuery()
    addField filmGraphQL.getByActorQuery()
  }
  mutations {
    addField filmGraphQL.getInsertMutation()
  }
}

Some final thoughts: