Skip to content

Can i apply schema directives to an object using inline types? #758

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

Closed
jensdenies opened this issue Dec 22, 2020 · 3 comments
Closed

Can i apply schema directives to an object using inline types? #758

jensdenies opened this issue Dec 22, 2020 · 3 comments
Labels

Comments

@jensdenies
Copy link

Hi,

Thanks for the great package, really enjoy working with it so far.

I was looking for a way to apply schema directives to an object type but I couldn't find a way to do so.

After digging around in the issues, I noticed a few other issues mentioning directives but it is not apparent to me whether this is supported when using inline types as opposed to the schema language.

Thanks.

@spawnia
Copy link
Collaborator

spawnia commented Dec 23, 2020

Directives are a concept that exists just within the schema definition language SDL, they have no direct runtime equivalent.

If you were to construct your schema from SDL, types hold a reference to the original AST node which contains the directives:

When you are not using SDL, you can just pass arbitrary extra config keys when constructing types:

$this->config = $config;

$foo = new ObjectType(['name' => 'Foo', 'arbitrary' => 123]);
$foo->config['arbitrary'];

@spawnia spawnia closed this as completed Dec 23, 2020
@jensdenies
Copy link
Author

Thanks @spawnia, I'll use your examples to get it working. Is it possible to get these directives to show up in the SDL when generating one through the SchemaPrinter?

@spawnia
Copy link
Collaborator

spawnia commented Dec 25, 2020

#552

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

2 participants