Closed
Description
Hi. It will be cool to let a developer select which style of schema's root resolver and type names to use. Or let him override it in a console (separately for an object and arrays).
In my case, I already have a frontend on ApolloStack (about 60000 lines of code) + backend on JoinMonster, and it's too hard to replace joinMonster to Hasura, because I need to transform schema, like this:
export default async function getSchema() {
const link = makeHttpAndWsLink(HASURA_GRAPHQL_ENGINE_URL, HASURA_ACCESS_KEY && { 'x-hasura-access-key': HASURA_ACCESS_KEY })
const schema = makeRemoteExecutableSchema({
schema: await introspectSchema(link),
link
})
return transformSchema(schema, [
new RenameTypes(type => pluralize.singular(capitalize(camelCase(type)))),
new RenameRootFields((operation, name) => {
let newName = name
if (name.includes('_by_pk')) {
newName = pluralize.singular(newName.replace('_by_pk', ''))
}
return camelCase(newName)
})
])
}
I want to:
- Type names must be in camelcase style
- Type names must begin with a capital letter
- Type names must be in the singular (even if the table name is in the plural) because it describes one object
- Root resolvers names must be in camelcase style
- Root resolvers names which returning arrays must be in the plural
- Root resolvers names which returning an object must be in the singular (_by_pk, for example)
Example:
Before:
user_parties: [user_parties!]!
user_parties_by_pk: user_parties
After:
userParties: [UserParty!]!
userParty: UserParty
Activity