You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have a factory for more dynamic runtime wiring #419
No its not spec - other than directives are in the spec to allow customisation by an engine.
The use of a "data fetcher factory" therefore allows you to look at the environment (from IDL from or from whatever takes your fancy) and allows you to switch in new DataFetchers rather than pure static wiring.
I have the use case in mind of using IDL directives to allow Schema specifiers to "specify" what they want perhaps by class name fieldX : String @dataFetcher(dataFetcher : "com.company.SecurityEnforcingDataFecter")
I second this. This will make using Dependency injection frameworks a lot more easily. You could let the framework build the components and then wire them into graphql.
Think about CDI/ Spring / Guice building the data fetchers and then the runtime injecting them by name/type in the proper place.
This can also allow AOP by means of adding directives that force some behaviors in a declarative way.
I believe this is quite an useful feature. Code generating libraries like graphql-apigee can benefit as well.
I'm not sure this is a good thing,
i think it's nice to have the api decoupled from the implementation completely,
and with adding this directive you tightly couple them together.
@dh94 this features doesn't enforce any tight coupling between the schema and the implementation. Yes, you can use it to to build something like @bbakerman suggested: adding meta informations (via directives) for DataFetchers and TypeResolvers. But you could also use it to select the DataFetcher based on some naming of the types for example.
In general it is just a way to connect schema and Implementation when the schema is created. It gives you more flexibility, if you need it or prefer it.
Activity
andimarek commentedon May 14, 2017
@bbakerman is there a graphql-js or spec reference?
bbakerman commentedon May 15, 2017
No its not spec - other than directives are in the spec to allow customisation by an engine.
The use of a "data fetcher factory" therefore allows you to look at the environment (from IDL from or from whatever takes your fancy) and allows you to switch in new DataFetchers rather than pure static wiring.
I have the use case in mind of using IDL directives to allow Schema specifiers to "specify" what they want perhaps by class name
fieldX : String @dataFetcher(dataFetcher : "com.company.SecurityEnforcingDataFecter")ieugen commentedon May 15, 2017
I second this. This will make using Dependency injection frameworks a lot more easily. You could let the framework build the components and then wire them into graphql.
Think about CDI/ Spring / Guice building the data fetchers and then the runtime injecting them by name/type in the proper place.
This can also allow AOP by means of adding directives that force some behaviors in a declarative way.
I believe this is quite an useful feature. Code generating libraries like graphql-apigee can benefit as well.
dh94 commentedon May 15, 2017
I'm not sure this is a good thing,
i think it's nice to have the api decoupled from the implementation completely,
and with adding this directive you tightly couple them together.
graphql-java#419 - dynamic runtime wiring factory support
Merge pull request #420 from bbakerman/419-dynamic-runtime-wiring-fac…
andimarek commentedon May 19, 2017
@dh94 this features doesn't enforce any tight coupling between the schema and the implementation. Yes, you can use it to to build something like @bbakerman suggested: adding meta informations (via directives) for DataFetchers and TypeResolvers. But you could also use it to select the DataFetcher based on some naming of the types for example.
In general it is just a way to connect schema and Implementation when the schema is created. It gives you more flexibility, if you need it or prefer it.
andimarek commentedon May 19, 2017
merged
Merge remote-tracking branch 'upstream/master'
vtahlani commentedon Jun 13, 2017
Do you have example for using dataFetcher directive. Below is my IDL schema
Schema get loaded successfully but looks like dataFetch not working.
Can we write custom function as part of dataResolver, the way we can do it with graphql-js? Can we call javaScript functions?
ieugen commentedon Jun 13, 2017
@vtahlani https://gist.github.com/ieugen/12e2ccf078c6d07032cc4a26d6dc53ac this might help.