Search code examples
laravelgraphqllaravel-lighthouse

Difference and example of Directives in FIELD and FIELD_DEFINITION


Like the title, I know the difference is the position of the directives, but my question is exists other difference? or advantage?


Solution

  • A FIELD directive is used client-side.

    query {
      someField @someDirective
    }
    

    A FIELD_DEFINITION directive is used server-side.

    type Query {
      someField: String @someDirective
    }
    

    Server-side directives affect how a schema is initially created. Client-side directives modify how an individual operation is executed.