GraphQL codegen?
# support
y
Hey folks! I'm wondering if there is an example or guidance around using the
graphql-codegen
library to generate type definitions for GraphQL queries & mutations. The main blocker I'm running into at the moment is auth: it doesn't seem like there's a straightforward way to configure the codegen utility with my app's client credentials. Has this been done before successfully?
r
We don't have any direct experience with that library, but we do publish the GraphQL schema that we enforce on the server-side https://graphiql.medplum.com/schema/schema-latest.json
If you'd like, you can download this for your own development
y
Thanks @rahul1 ! That was extremely helpful. We're at the stage where we have Apollo client with codegen running. However, when the client queries the GraphQL server, by default it adds
_typenames
to each node of the query, which it then uses for caching and type validation. However, when
__typenames
is included in the query, the server responds with a 403. Because of this, we suppress the client from querying for
__typenames
. This allows us to actually make queries. This is causing us some issues. Most crucially, Apollo is stripping out any data we get via inline fragments, since it apparently uses
__typenames
to verify that the data matches against a list of possible types. We're wondering - would it be possible for the GraphQL server to allow us to query for
__typenames
?
r
Hi @yale_77214 , let me get back to you on that. I believe this could be something we purposely had to supress this for security reasons. I think this came back in a pen test. But I'll dig into this and get back to you
y
Thank you @rahul1!
r
Good news @yale_77214 . Introspection queries are actualy a project-level feature that we can enable for you. If you can DM you're project ID, i'll turn that on
y
@rahul1 AMAZING, that's wonderful news. Will DM a project ID now.
r
should now be enabled
@yale_77214 - We've got this PR out to get this working. Should be merged by EOD: https://github.com/medplum/medplum/pull/2700#pullrequestreview-1590320820
y
AWESOME, that's great news. Thank you so much.
r
@yale_77214 , just wanted to update you that this has been merged
y
Woohoo!!! Confirmed, it's working. Thank you 🙂
164 Views