web-ridge / sqlboiler-graphql-schema

MOVED TO https://github.com/web-ridge/gqlgen-sqlboiler
7 stars 2 forks source link

Make this a go library so we have type safe params #6

Open RichardLindhout opened 4 years ago

RichardLindhout commented 4 years ago

I'm thinking about making this a library in the future so we can have hooks which can customize fields before writing it to file or have custom hooks still not really sure if it's a good idea.

I think it has the following advantages

e.g. putting we could do more advanced things if user like to re-create schema withouth many merging conflicts

Not real syntax but to give an idea

err := writeSchema(sqlboiler_graphql_schema.Config{
      TopWriter: (w writer) {
         w.write(`
directive @isAuthenticated on FIELD_DEFINITION
scalar Upload
`)
      },
      EnhanceModel: func(model sqlboiler_graphql_schema.GeneredStruct){
          // you could skip input fields here

     },
     BeforeModel: func(model sqlboiler_graphql_schema.GeneredStruct){}
     AfterModel: func(model sqlboiler_graphql_schema.GeneredStruct){}
    EnhanceListQuery: func(model sqlboiler_graphql_schema.GeneredStruct){
          // you could change arguments ..
     },
     BeforeQueries: func(writer) {
w.Write(`
// write extra queries here

`)
     AfterQueries: func(writer) {
w.Write(`
// write extra queries here

`)
AfterMutations: func(writer) {
w.Write(`
// write extra mutations here

`)
}

})

cc: @troian

RichardLindhout commented 4 years ago

We're building this approach slowly in the development branch: https://github.com/web-ridge/gqlgen-sqlboiler/tree/development

RichardLindhout commented 4 years ago

But less hooky but you have the option to change your schema completely + adding your own custom schema's with the multiple schema option of gqlgen