Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPIC: Directive support #760

Open
vektah opened this issue Jun 26, 2019 · 5 comments
Open

EPIC: Directive support #760

vektah opened this issue Jun 26, 2019 · 5 comments
Labels

Comments

@vektah
Copy link
Collaborator

vektah commented Jun 26, 2019

Here to track the status of directives

⚠️ 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. ⚠️

Execution directives

location implemented obj is
QUERY ✔️ #744 *ast.OperationDefinition
MUTATION ✔️ #744 *ast.OperationDefinition
SUBSCRIPTION ✔️ #744 *ast.OperationDefinition
FIELD ✔️ #756 parent type
FRAGMENT_DEFINITION
FRAGMENT_SPREAD
INLINE_FRAGMENT

Schema directives

location implemented obj is
SCHEMA
SCALAR
OBJECT ✔️ #1117 parent type
FIELD_DEFINITION ✔️ parent type
ARGUMENT_DEFINITION ✔️ #460 argument bag
INTERFACE
UNION
ENUM
ENUM_VALUE
INPUT_OBJECT
INPUT_FIELD_DEFINITION ✔️ 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

@stale
Copy link

stale bot commented Aug 28, 2019

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.

@stale stale bot added the stale label Aug 28, 2019
@stale stale bot closed this as completed Sep 4, 2019
@vektah vektah removed the stale label Sep 22, 2019
@vektah vektah reopened this Sep 22, 2019
@dbadura
Copy link

dbadura commented Oct 30, 2019

Hello,
what happen with directive on ARGUMENT_DEFINITION?

@dtrckd
Copy link

dtrckd commented Jun 28, 2020

Hi,
I've commented on a potential problem with OBJECT directive, here.

@logrusorgru
Copy link

logrusorgru commented Dec 12, 2020

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.

  1. The gqlgen generator doesn't allow directives with INPUT_FIELD_DEFINITION on input fields. But allows them on the input fields with FIELD_DEFINITION.
  2. Object received in a directive handler is map[string]interface{}, not a Go object. Is it by design? Why not Go object?
  3. 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.

@dangolbeeker
Copy link

dangolbeeker commented May 10, 2021

Have you found a patch yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants