Replies: 4 comments 4 replies
-
Hi @Yao544303, graphql-java supports both TypeSystemDirectiveLocation (for Schema Directives) and ExecutableDirectiveLocation (for Query Directives, also known as Operation Directives). You can see all the supported directive locations in this enum: Thanks for pointing out that our documentation only seems to refer to Schema Directives! I will add a new page for Query/Operation Directives as well. I like the example you provided, I'll build on that. It will take me a while to write a page with a tutorial, but in the meantime if anybody has an example, feel free to add to this discussion. |
Beta Was this translation helpful? Give feedback.
-
+1 would also like the above |
Beta Was this translation helpful? Give feedback.
-
Any update on this? I can't find any example on how to implement Query directives. |
Beta Was this translation helpful? Give feedback.
-
Currently, seems it only supports the TypeSystemDirectiveLocation,
is there any plan to support the ExecutableDirectiveLocation in the future?
Or is any idea to implement ExecutableDirectiveLocation?
For example, here is the schema.graphqls
`
directive @uppercase on FIELD
type Query {
bookById(id: ID): Book
}
type Book {
id: ID
name: String
pageCount: Int
author: String
}`
Need return
{ "data": { "bookById": { "id": "book-1", "name": "Effective Java", "pageCount": 416, "author": "author-1", } } }
for query
query bookDetails { bookById(id: "book-1") { id name pageCount author } }
And return
{ "data": { "bookById": { "id": "book-1", "name": "Effective Java", "pageCount": 416, "author": "AUTHOR-1", } } }
for query
query bookDetails { bookById(id: "book-1") { id name pageCount author @uppercase } }
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions