I'm beginning development on a nontrivial application for which we're considering GraphQL. When working on the initial draft of our schema, I've become a bit paralyzed trying to establish naming conventions that will scale as the product matures. I would really appreciate some insight from anyone who has had to grow a schema and run into, or successfully avoided dead ends or inconsistencies:
Is it generally useful/idiomatic to keep the name "Interface" in the name of an interface? For example, would
Profile
orProfileInterface
be preferable in a large app?interface ProfileInterface { # fields here... } type UserProfile implements ProfileInterface { # implemented fields here... }
Is it common to specify single-enum values as "constants"?
enum GeoJSONFeatureTypeConstant { feature } interface GeoJSONFeatureInterface { id: ID type: GeoJSONFeatureTypeConstant! geometry: GeoJSONGeometryInterface! properties: GeoJSONProperties }
Is it best practice to declare all-or-nothing
object
s asscalar
ortype
, and where is the line drawn between the two? Imagine aPoint
type that is would typically be represented as an array[x,y]
; which would be more idiomadic?scalar Point type Point { x: Float y: Float }
- Any other best-practices specifically related to naming conventions or type declarations in GraphQL that would be difficult to know without experience.
Thanks in advance!
This question hasn't gained the momentum I would have liked, so I'm going to start posting useful snippets as I find them, which may evolve into an answer of sorts.
Naming input types with Input on the end is a useful convention, because you will often want both an input type and an output type that are slightly different for a single conceptual object.