Server architecture for large schemas. Type extensions?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- fsharp, graphql
- Domain
- api, backend-api-design
Research direction
Start by reviewing the described User.fs, Organization.fs, and Query.fs layout alongside the GraphQL Object Extensions specification linked in the issue. Determine whether the library has an existing schema or object-definition entry point for this architecture. Done would mean an agreed recommendation or a clearly scoped implementation plan for cross-file relationship fields and extensions.
Written by the indexing model from the issue text.
Description
My team is migrating an existing GraphQL API from JS to F#. Our API has a lot of types, so we decided to create a file per type (Define.Object).
The file structure looks like this:
- Schema
- User.fs
- Organization.fs
- ...
- Query.fs
If Organization has a users field that returns ListOf User, you can simply compile User.fs before Organization.fs.
However, this doesn't work if User also needs to have an organizations field, because F# doesn't allow mutual recursion across files.
What is the recommended way to architecture a big server like this? The samples use a single schema file, but unfortunately, that's just not feasible for our use case. If we did this, we would eventually have a file with 20K+ lines of code (judging by the size of our JS API).
A solution might be supporting Type Extensions. Especially, Object Extensions: http://spec.graphql.org/June2018/#sec-Object-Extensions
With Object Extensions, we would be able to define these relationship fields at the return type module instead. In my example, Organization.fs would add the organizations field to the User type, and User.fs would add the users field to the Organization type.
This architecture would work out pretty nicely for us because the querying and authorization logic needed to return records of a type would remain in its module as opposed to being spread across the codebase.
Supporting GraphQL extensions would also allow users of this library to build GraphQL microservices, that could be composed using tools like Apollo Federation.
If you think that's a good idea, I'd be more than happy to contribute. Thanks!
- Dominant language
- F#
- Stars
- 406
- Forks
- 74
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 14
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fsprojects/FSharp.Data.GraphQL
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
fsprojects/FSharp.Data.GraphQL#573 · 1 reaction · 2 assignees ·
-
FR: Suave package Open
fsprojects/FSharp.Data.GraphQL#566 · 1 comment · 1 reaction · 2 assignees ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in fsprojects/FSharp.Data.GraphQL
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
avniproject/avni-client#2135 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
good first issue refactor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100