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

Schema composition order matters and causes query planner errors #1440

Open
YassineElbouchaibi opened this issue Dec 12, 2024 · 2 comments
Open
Assignees
Labels
awaiting feedback Awaiting for original poster feed back to questions and comments asked by the team. internally-reviewed The issue has been reviewed internally.

Comments

@YassineElbouchaibi
Copy link
Contributor

Hello, it seems the order in which you publish schemas to the control plane matters and will cause issues down the line.

Here is a scenario I am experiencing:

  1. Publish subgraph A's schema defining type X
  2. Publish subgraph B's schema extending type X
  3. Publish subgraph A's schema defining type X with a minor change unrelated to type X
  4. At this point if you have subgraph C with type Y which has an attribute of type X, the subgraph seems to crash.

I am sorry I cannot provide full repro steps at this point as I am on mobile, I will provide a github repo later.

The error starts happening after this PR (#1092) which is released in [email protected]

In the mean time here is the error message from the router v0.107.4 up to v0.151.1. This one is specifically from 0.117.0 with minor stuff redacted:

ERROR internal error {"hostname": "*******", "pid": 1, "component": "@wundergraph/router", "service_version": "0.117.0", "reqId": "*******/*******", "error": "1 error occurred:\n\t* failed to obtain planning paths: failed to create planning paths, missing paths: [query.someQuery.request.data.someAttribute.$1ThisIsTheTypeX.__typename], has field waiting for dependency: false\n\n"}
github.com/wundergraph/cosmo/router/core.logInternalErrorsFromReport
        github.com/wundergraph/cosmo/router/core/errors.go:89
github.com/wundergraph/cosmo/router/core.writeOperationError
        github.com/wundergraph/cosmo/router/core/errors.go:173
github.com/wundergraph/cosmo/router/core.(*PreHandler).Handler-fm.(*PreHandler).Handler.func1
        github.com/wundergraph/cosmo/router/core/graphql_prehandler.go:306
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/core.NewWebsocketMiddleware.func1.1
        github.com/wundergraph/cosmo/router/core/websocket.go:136
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/internal/graphiql.(*Playground).ServeHTTP
        github.com/wundergraph/cosmo/router/internal/graphiql/playgroundhandler.go:33
github.com/wundergraph/cosmo/router/internal/requestlogger.(*handler).ServeHTTP
        github.com/wundergraph/cosmo/router/internal/requestlogger/requestlogger.go:199
github.com/wundergraph/cosmo/router/pkg/trace.(*Middleware).Handler.func1
        github.com/wundergraph/cosmo/router/pkg/trace/middleware.go:52
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*middleware).serveHTTP
        go.opentelemetry.io/contrib/instrumentation/net/http/[email protected]/handler.go:229
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.NewMiddleware.func1.1
        go.opentelemetry.io/contrib/instrumentation/net/http/[email protected]/handler.go:81
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/core.(*graphServer).buildGraphMux.func5.1
        github.com/wundergraph/cosmo/router/core/graph_server.go:522
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/core.(*graphServer).buildGraphMux.func4.1
        github.com/wundergraph/cosmo/router/core/graph_server.go:503
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/go-chi/chi/v5.(*Mux).ServeHTTP
        github.com/go-chi/chi/[email protected]/mux.go:73
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/go-chi/chi/v5.(*Mux).Mount.func1
        github.com/go-chi/chi/[email protected]/mux.go:315
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/klauspost/compress/gzhttp.NewWrapper.func1.1
        github.com/klauspost/[email protected]/gzhttp/compress.go:495
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/go-chi/chi/v5.(*ChainHandler).ServeHTTP
        github.com/go-chi/chi/[email protected]/chain.go:31
github.com/go-chi/chi/v5.(*Mux).routeHTTP
        github.com/go-chi/chi/[email protected]/mux.go:443
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/pkg/cors.(*cors).ServeHTTP
        github.com/wundergraph/cosmo/router/pkg/cors/config.go:74
github.com/go-chi/chi/v5/middleware.RealIP.func1
        github.com/go-chi/chi/[email protected]/middleware/realip.go:36
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/go-chi/chi/v5/middleware.RequestID.func1
        github.com/go-chi/chi/[email protected]/middleware/request_id.go:76
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/core.newGraphServer.RequestSize.func9.1
        github.com/wundergraph/cosmo/router/internal/middleware/request_size.go:14
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
github.com/wundergraph/cosmo/router/internal/recoveryhandler.(*handler).ServeHTTP
        github.com/wundergraph/cosmo/router/internal/recoveryhandler/recovery.go:39
github.com/go-chi/chi/v5.(*Mux).ServeHTTP
        github.com/go-chi/chi/[email protected]/mux.go:90
github.com/wundergraph/cosmo/router/core.newServer.func1
        github.com/wundergraph/cosmo/router/core/http_server.go:62
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2141
net/http.serverHandler.ServeHTTP
        net/http/server.go:2943
net/http.(*conn).serve
        net/http/server.go:2014

For now a workaround seems to be to republish subgraph B's schema extending type X.

I'm sorry for not following the standard format, I will tweak this issue later.

Copy link

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

@Noroth Noroth added awaiting feedback Awaiting for original poster feed back to questions and comments asked by the team. internally-reviewed The issue has been reviewed internally. labels Dec 17, 2024
@YassineElbouchaibi
Copy link
Contributor Author

Here is a github that allows repro: https://github.com/YassineElbouchaibi/cosmo-issue-1440-repro

Steps to start a router that works and one that breaks depending on the composition order are in the readme as well as an example query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting for original poster feed back to questions and comments asked by the team. internally-reviewed The issue has been reviewed internally.
Projects
None yet
Development

No branches or pull requests

3 participants