Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 34 forks source link

support virtual properties through dedicated schema #55

Closed timhuff closed 6 years ago

timhuff commented 6 years ago

This provides support for virtual properties, even with select filtering on. Not crazy about the API but the types need to be specified somewhere. I considered adding a boolean virtual property to the existing json schema props but I don't think that's compliant with the spec.

p.s. Sorry about the two other erroneous pull requests - in a bit of a rush.

timhuff commented 6 years ago

@nasushkov I feel this might be a good one to start on once you get some time. I realized after submitting it that I had possibly accidentally resolved #51 with it (or gotten close). But I think this will also be a good jumping off point for the discussion of "using objection model properties as GraphQL configurations - yay or nay?". It seems like it might be more palatable if we pick a single property (maybe graphqlConfig or something) and put everything in there.

nasushkov commented 6 years ago

Hi @timhuff do you want to provide a fine-grained configuration with exact fields in the graphqlConfig or something more high level like: graphqlConfig: { useSchema: true, useRelations: true, useVirtualProps: false, } I think by default the schema should be generated with all options set to true and if you want to fine-tune your generated schema, you can configure the output with this extra field.

nasushkov commented 6 years ago

@timhuff I think we can merge this for now and get back to a more general solution in the future

timhuff commented 6 years ago

@nasushkov Yea, I was thinking more along the lines of the high level example. But then the high level one would also have a virtualProps property (which I think could replace useVirtualProps). So something like graphqlConfig: { useSchema: true, useRelations: true, virtualProps: {fullName: {type: "string"}}}