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

Adding Directives to Schemas #105

Closed
MDrooker opened this issue Jun 23, 2018 · 6 comments
Closed

Adding Directives to Schemas #105

MDrooker opened this issue Jun 23, 2018 · 6 comments

Comments

@MDrooker
Copy link

MDrooker commented Jun 23, 2018

Hey All-
We are looking to use the new ApolloServer 2.0 features around CDN integration for some of our services-

https://www.apollographql.com/docs/apollo-server/v2/features/cdn.html

Any suggestions around how to get the directives added to some of the types output by graphql-compose-mongoose?

@st0ffern
Copy link

st0ffern commented Jun 23, 2018

If i understood you correct, you want to cache queries made to db?
Just wrap it with DataLoader and you have solved the issue with queries to mongodb:
https://github.com/graphql-compose/graphql-compose-dataloader

For external or other queries see facebooks DataLoader:
https://github.com/facebook/dataloader

@MDrooker
Copy link
Author

We want to put a CDN infront of our service to help scale it under load. The Dataloader only helps with the calls to Mongo. A CDN will cache the request/response so it serves from the edge vs the origin servers.

@st0ffern
Copy link

st0ffern commented Jun 24, 2018

That is not implemented in graphql-compose.
I think it would be a easy task to make a middeware for it that attaches to the TCs that does this.

In our environment, we use serverless for automatic AWS deployment and run everything in lambda as it is autoscaling and you only pay pr runtime as it is really cheap

@marckline
Copy link

One can imagine other use cases. For example, the schema directive that brought me here is https://github.com/confuser/graphql-constraint-directive. Others might want to create custom schema directives for their own servers (e.g. via https://www.apollographql.com/docs/graphql-tools/schema-directives.html). But there doesn't seem to be any documented or undocumented way of adding these to types unless I'm missing it?

@nodkz
Copy link
Member

nodkz commented Jun 29, 2018

Adding directives via GraphQL*Type classes was rejected by Lee Byron graphql/graphql-js#1262

It will be good if you write about your needs and use cases in the 1262 issue. Right now there is no way to add directives via GraphQL*Type classes in graphql-js. That's why graphql-compose which works on top of its classes does not allow to provide directives for fields when you define types.

@marc-money
Copy link

Thanks. I understand, and after exploring the topic some more, it looks to me like @19majkel94 did a good job making the same case I might have in graphql/graphql-js#1343

It also looks like a related topic was discussed at a WG meeting a few months back: https://github.com/graphql/graphql-wg/blob/master/notes/2018-02-01.md#exposing-schema-metadata. Maybe some progress will be made soon.

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

5 participants