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

How can I add schema directives? #617

Closed
codler opened this issue Feb 7, 2020 · 4 comments
Closed

How can I add schema directives? #617

codler opened this issue Feb 7, 2020 · 4 comments

Comments

@codler
Copy link

codler commented Feb 7, 2020

I like to create Enforcing access permissions as described here, so I can do Authorization and ACL
https://www.apollographql.com/docs/graphql-tools/schema-directives/#enforcing-access-permissions
I cant find anything in the documentation

@vladar
Copy link
Member

vladar commented Feb 26, 2020

You should be able to use directives the same way in SDL (see this example from tests - at the very bottom). Those directives should be available on type instance via $type->astNode or $type->extensionASTNodes (if type was extended).

@Tyler-Gauch
Copy link

@vladar How can you use schema directives from php when extending ObjectType. Do I need to pass an extension/ASTNode in the $config?

@mwijngaard
Copy link

@Tyler-Gauch directives are not intended to be used this way, see: graphql/graphql-js#746 (comment) . You can inject your own metadata into the config object for tracking runtime information.

@vladar
Copy link
Member

vladar commented Jun 8, 2020

@mwijngaard You are right. We will also add extensions feature in one of the next versions. But for now, just use a custom config. It still makes sense to keep custom metadata under extensions config key.

Closing this but feel free to re-open if you want to continue the discussion.

@vladar vladar closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants