Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

[Question] With large resource collections, how can I enforce "first" to be less than, say, 100? #57

Open
seandavi opened this issue Mar 2, 2020 · 3 comments

Comments

@seandavi
Copy link

seandavi commented Mar 2, 2020

I'm used to working on python/graphene, so my question is likely simply a matter of my not being familiar with graphql-js and how neo4j-graphql fits in.

@BrenoMazieiro
Copy link

BrenoMazieiro commented Mar 2, 2020

Do you mean something like that?

type Query {
  usersBySubstring(substring: String, first: Int): [User]
    @cypher(
      statement: "MATCH (u:User) WHERE u.name CONTAINS $substring LIMIT $first RETURN u"
    )
}

@seandavi
Copy link
Author

seandavi commented Mar 2, 2020

Thanks, @BrenoMazieiro.

Yes. I'd like to enforce that "first" is specified in the graphql query and is 100 or less (or default to 100) for all collections (as an example). I am exposing a graphql API to the public and want to do what I can to protect the resource.

Of course, any other suggestions on the general topic of public graphql apis backed by neo4j would be much appreciated.

@BrenoMazieiro
Copy link

@seandavi this is an "example repository", I believe it is not for production, you should do a lot of things if you want something "production like", like adding authentication and authorization at least.

Anyway:

Whats about this?

type Query {
  usersBySubstring(substring: String, first: Int = 100): [User]
    @cypher(
      statement: "MATCH (u:User) WHERE u.name CONTAINS $substring LIMIT $first RETURN u"
    )
}

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

No branches or pull requests

2 participants