graphile / crystal-pre-merge

Repository moved
https://github.com/graphile/crystal
39 stars 10 forks source link

Give makeExtendSchemaPlugin a way of associating scopes with the created types #476

Closed benjie closed 5 months ago

benjie commented 11 months ago

e.g. to have the edges be auto-added to a mutation payload you'd need to add the scopes:

isMutationPayload: true,
pgTypeResource: myResource,

In V4 you'd do this with the @scope directive; but no such directive exists in V5 currently (there's a "TODO" to add support).

Maybe, rather than using the directive (which was always an ugly hack) we can add a scopes key to the callback result:

return {
  typeDefs: ...,
  scopes: {
    object: {
      CustomCreateDependencyPayload: {
        isMutationPayload: true,
        pgTypeResource: myResource,
      }
    },
    field: {
      MyType: { 
        myField: {
          // scope here
        }
      }
    }
  },
  plans: { ... }
};

This could be done strongly typed, so is definitely preferable.

Context: https://discord.com/channels/489127045289476126/1139362114595729482/1139483239401136239

Need expressed by: @sgrove