Gqlgen: New Proposal: Mark field as resolver with graphql directives

Created on 24 May 2019  路  2Comments  路  Source: 99designs/gqlgen

Right now you can either use custom defined models compare with schema.graphql definition to generate resolvers.

Or you can use gqlgen.yml to config resolvers like

models:
  Topic:
    fields:
      replies:
        resolver: true

I suggest another way to mark a field as resolver by using https://graphql.github.io/graphql-spec/draft/#sec-Type-System.Directives

For example:

directive @resolver on FIELD_DEFINITION

type Topic {
    id: ID!
    title: String!
    replies: [Reply!] @resolver
}

This way, Field definition and whether it is a resolver are in the same place. So you won't forget to remove one or another when changing

v0.9.1

Most helpful comment

Yeah there are a bunch of these, @model, @resolver, @name could be interesting

All 2 comments

Yeah there are a bunch of these, @model, @resolver, @name could be interesting

Done!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ksoda picture ksoda  路  3Comments

huanghantao picture huanghantao  路  3Comments

cajax picture cajax  路  4Comments

RobertoOrtis picture RobertoOrtis  路  3Comments

bieber picture bieber  路  4Comments