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

Handle non-src dirs for TypeScript documents #10792

Merged
merged 3 commits into from
Sep 14, 2023

Conversation

ddimaria
Copy link
Contributor

The static typing docs don't include documents outside of the src folder and .ts files. I made a note beneath the code block. The error messages generated aren't overly helpful:

Invariant Violation: Argument of [object Object] passed to parser was not a valid GraphQL DocumentNode. You may need to use 'graphql-tag' or another method to convert your operation into a document

This will be problematic for anyone upgrading to using the App Router in NextJS v13.

@ddimaria ddimaria requested a review from StephenBarlow as a code owner April 21, 2023 18:48
@apollo-cla
Copy link

@ddimaria: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@netlify
Copy link

netlify bot commented Apr 21, 2023

👷 Deploy request for apollo-client-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b55672c

@changeset-bot
Copy link

changeset-bot bot commented Apr 21, 2023

⚠️ No Changeset found

Latest commit: b55672c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -44,6 +44,8 @@ export default config;

> There are multiple ways to [specify a schema](https://www.the-guild.dev/graphql/codegen/docs/config-reference/schema-field#root-level) in your `codegen.ts`, so pick whichever way works best for your project setup.

> Your `documents` might exist in directories other than `src` and may include `ts` files, please adjust accordingly. To catch everything, consider implementing: `documents: ['**/*.{ts,tsx}']`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be more discoverable to people to have this as a comment in the above code example.

For example:

const config: CodegenConfig = {
  schema: '<URL_OF_YOUR_GRAPHQL_API>',
+  // this assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure  
+  documents: ['src/**/*.{ts,tsx}'],
-  documents: ['src/**/*.tsx'],
  generates: {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied these suggestions to get this PR out.

@phryneas
Copy link
Member

phryneas commented Apr 24, 2023

This will be problematic for anyone upgrading to using the App Router in NextJS v13.

Do you mean that because there is now a top-level app directory? To my knowledge, there is still the option to have a src directory, which means you would end up with src/app.

Generally, it can't be said enough: please be very careful with anything regarding the app directory. That is still very much unstable on the Next.js side, and we are still exploring how we can best support that. At this point, expect that both Next.js itself and every external library will break and don't use it for any kind of production project!

@phryneas phryneas requested a review from a team as a code owner September 14, 2023 14:43
@phryneas phryneas merged commit 9908ab4 into apollographql:main Sep 14, 2023
4 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants