gqlgen
gqlgen copied to clipboard
EPIC: Directive support
Here to track the status of directives
:warning: these features are subject to change - if you are using any of these features make sure you have tests on your directives that actually run queries against a graph. :warning:
Execution directives
location | implemented | obj is |
---|---|---|
QUERY | :heavy_check_mark: https://github.com/99designs/gqlgen/pull/744 | *ast.OperationDefinition |
MUTATION | :heavy_check_mark: https://github.com/99designs/gqlgen/pull/744 | *ast.OperationDefinition |
SUBSCRIPTION | :heavy_check_mark: https://github.com/99designs/gqlgen/pull/744 | *ast.OperationDefinition |
FIELD | :heavy_check_mark: https://github.com/99designs/gqlgen/pull/756 | parent type |
FRAGMENT_DEFINITION | :no_entry: | |
FRAGMENT_SPREAD | :no_entry: | |
INLINE_FRAGMENT | :no_entry: |
Schema directives
location | implemented | obj is |
---|---|---|
SCHEMA | :no_entry: | |
SCALAR | :no_entry: | |
OBJECT | :heavy_check_mark: https://github.com/99designs/gqlgen/pull/1117 | parent type |
FIELD_DEFINITION | :heavy_check_mark: | parent type |
ARGUMENT_DEFINITION | :heavy_check_mark: https://github.com/99designs/gqlgen/pull/460 | argument bag |
INTERFACE | :no_entry: | |
UNION | :no_entry: | |
ENUM | :no_entry: | |
ENUM_VALUE | :no_entry: | |
INPUT_OBJECT | :no_entry: | |
INPUT_FIELD_DEFINITION | :heavy_check_mark: | parent input |
Schema field directives on subscriptions
obj is always nil for any root (Query, Mutation, Subscription) next() returns a channel of the field type
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hello,
what happen with directive on ARGUMENT_DEFINITION
?
Hi, I've commented on a potential problem with OBJECT directive, here.
Hi, there.
There are a few questions about directives. Commonly most about INPUT_FIELD_DEFINITION. It is marked with a check mark and its input object is a parent object.
- The gqlgen generator doesn't allow directives with INPUT_FIELD_DEFINITION on input fields. But allows them on the input fields with FIELD_DEFINITION.
- Object received in a directive handler is map[string]interface{}, not a Go object. Is it by design? Why not Go object?
- The following directive produce invalid server that panics just before the directive called
directive @allowValueType (field: String!, allow: [ValueTypeAllow!]) on
INPUT_FIELD_DEFINITION |
FIELD_DEFINITION # <- have to add
enum ValueType {
ONE
TWO
}
input ValueTypeAllow {
valueType: ValueType!
allow: Boolean!
}
input InputValue {
name: String!
valueType: ValueType! @allowValueType (field: "valueType", allow: [
ValueTypeAllow{valueType: ONE, allow: true},
ValueTypeAllow{valueType: TWO, allow: true}
])
}
However, it's okay with the 3rd point if the directive receives strings for example
directive @allowValueType (field: String!, allow: [String!]) on
INPUT_FIELD_DEFINITION |
FIELD_DEFINITION # <- have to add
input InputValue {
name: String!
valueType: ValueType! @allowValueType (field: "valueType", allow: [
"ONE:true",
"TWO:true"
])
}
There is repository that represents all of them https://github.com/logrusorgru/gqlif . It can be cloned and executed with go run main.go
. Then, trying to execute
mutation a($name: String!, $value: InputValue!) {
set (name: $name, value: $value) {name valueType}
}
with
{"name": "pew-pew", "value": {"name": "one", "valueType": "ONE"}}
You will got the panic.
Best regards.
Have you found a patch yet?