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

fix(deps): update graphqlcodegenerator monorepo #8012

Merged
merged 6 commits into from
Apr 26, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Apr 4, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@graphql-codegen/cli 3.2.2 -> 3.3.0 age adoption passing confidence
@graphql-codegen/typescript 3.0.2 -> 3.0.3 age adoption passing confidence
@graphql-codegen/typescript-operations 3.0.2 -> 3.0.3 age adoption passing confidence
@graphql-codegen/typescript-resolvers 3.1.1 -> 3.2.0 age adoption passing confidence

Release Notes

dotansimha/graphql-code-generator (@​graphql-codegen/cli)

v3.3.0

Compare Source

Minor Changes
  • #​9151 b7dacb21f Thanks @​'./user/schema.mappers#UserMapper',! - Add watchPattern config option for generates sections.

    By default, watch mode automatically watches all GraphQL schema and document files. This means when a change is detected, Codegen CLI is run.

    A user may want to run Codegen CLI when non-schema and non-document files are changed. Each generates section now has a watchPattern option to allow more file patterns to be added to the list of patterns to watch.

    In the example below, mappers are exported from schema.mappers.ts files. We want to re-run Codegen if the content of *.mappers.ts files change because they change the generated types file. To solve this, we can add mapper file patterns to watch using the glob pattern used for schema and document files.

    // codegen.ts
    const config: CodegenConfig = {
      schema: 'src/schema/**/*.graphql',
      generates: {
        'src/schema/types.ts': {
          plugins: ['typescript', 'typescript-resolvers'],
          config: {
            mappers: {
    
              Book: './book/schema.mappers#BookMapper',
            },
          }
          watchPattern: 'src/schema/**/*.mappers.ts', // Watches mapper files in `watch` mode. Use an array for multiple patterns e.g. `['src/*.pattern1.ts','src/*.pattern2.ts']`
        },
      },
    };

    Then, run Codegen CLI in watch mode:

    yarn graphql-codegen --watch

    Now, updating *.mappers.ts files re-runs Codegen! 🎉

    Note: watchPattern is only used in watch mode i.e. running CLI with --watch flag.

Patch Changes
dotansimha/graphql-code-generator (@​graphql-codegen/typescript)

v3.0.3

Compare Source

Patch Changes
dotansimha/graphql-code-generator (@​graphql-codegen/typescript-operations)

v3.0.3

Compare Source

Patch Changes
dotansimha/graphql-code-generator (@​graphql-codegen/typescript-resolvers)

v3.2.0

Compare Source

Minor Changes
  • #​9146 9f4d9c5a4 Thanks @​eddeee888! - [typescript-resolvers] Add resolversNonOptionalTypename config option.

    This is extending on ResolversUnionTypes implemented in https://github.com/dotansimha/graphql-code-generator/pull/9069

    resolversNonOptionalTypename adds non-optional __typename to union members of ResolversUnionTypes, without affecting the union members' base intefaces.

    A common use case for non-optional __typename of union members is using it as the common field to work out the final schema type. This makes implementing the union's __resolveType very simple as we can use __typename to decide which union member the resolved object is. Without this, we have to check the existence of field/s on the incoming object which could be verbose.

    For example, consider this schema:

    type Query {
      book(id: ID!): BookPayload!
    }
    
    type Book {
      id: ID!
      isbn: String!
    }
    
    type BookResult {
      node: Book
    }
    
    type PayloadError {
      message: String!
    }
    
    union BookPayload = BookResult | PayloadError

    With optional __typename: We need to check existence of certain fields to resolve type in the union resolver:

    // Query/book.ts
    export const book = async () => {
      try {
        const book = await fetchBook();
        // 1. No `__typename` in resolver results...
        return {
          node: book,
        };
      } catch (e) {
        return {
          message: 'Failed to fetch book',
        };
      }
    };
    
    // BookPayload.ts
    export const BookPayload = {
      __resolveType: parent => {
        // 2. ... means more checks in `__resolveType`
        if ('message' in parent) {
          return 'PayloadError';
        }
        return 'BookResult';
      },
    };

    With non-optional __typename: Resolvers declare the type. This which gives us better TypeScript support in resolvers and simplify __resolveType implementation:

    // Query/book.ts
    export const book = async () => {
      try {
        const book = await fetchBook();
        // 1. `__typename` is declared in resolver results...
        return {
          __typename: 'BookResult', // 1a. this also types `node` for us 🎉
          node: book,
        };
      } catch (e) {
        return {
          __typename: 'PayloadError',
          message: 'Failed to fetch book',
        };
      }
    };
    
    // BookPayload.ts
    export const BookPayload = {
      __resolveType: parent => parent.__typename, // 2. ... means a very simple check in `__resolveType`
    };

    Using resolversNonOptionalTypename: add it into typescript-resolvers plugin config:

    // codegen.ts
    const config: CodegenConfig = {
      schema: 'src/schema/**/*.graphql',
      generates: {
        'src/schema/types.ts': {
          plugins: ['typescript', 'typescript-resolvers'],
          config: {
            resolversNonOptionalTypename: true, // Or `resolversNonOptionalTypename: { unionMember: true }`
          },
        },
      },
    };
Patch Changes
  • #​9206 e56790104 Thanks @​eddeee888! - Fix ResolversUnionTypes being used in ResolversParentTypes

    Previously, objects with mappable fields are converted to Omit format that references its own type group or ResolversTypes or ResolversParentTypes e.g.

    export type ResolversTypes = {
      Book: ResolverTypeWrapper<BookMapper>;
      BookPayload: ResolversTypes['BookResult'] | ResolversTypes['StandardError'];
      // Note: `result` on the next line references `ResolversTypes["Book"]`
      BookResult: ResolverTypeWrapper<Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }>;
      StandardError: ResolverTypeWrapper<StandardError>;
    };
    
    export type ResolversParentTypes = {
      Book: BookMapper;
      BookPayload: ResolversParentTypes['BookResult'] | ResolversParentTypes['StandardError'];
      // Note: `result` on the next line references `ResolversParentTypes["Book"]`
      BookResult: Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> };
      StandardError: StandardError;
    };

    In https://github.com/dotansimha/graphql-code-generator/pull/9069, we extracted resolver union types to its own group:

    export type ResolversUnionTypes = {
      // Note: `result` on the next line references `ResolversTypes["Book"]` which is only correct for the `ResolversTypes` case
      BookPayload: (Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }) | StandardError;
    };
    
    export type ResolversTypes = {
      Book: ResolverTypeWrapper<BookMapper>;
      BookPayload: ResolverTypeWrapper<ResolversUnionTypes['BookPayload']>;
      BookResult: ResolverTypeWrapper<Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }>;
      StandardError: ResolverTypeWrapper<StandardError>;
    };
    
    export type ResolversParentTypes = {
      Book: BookMapper;
      BookPayload: ResolversUnionTypes['BookPayload'];
      BookResult: Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> };
      StandardError: StandardError;
    };

    This change creates an extra ResolversUnionParentTypes that is referenced by ResolversParentTypes to ensure backwards compatibility:

    export type ResolversUnionTypes = {
      BookPayload: (Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> }) | StandardError;
    };
    
    // ... and the reference is changed in ResolversParentTypes:
    export type ResolversParentTypes = {
      // ... other fields
      BookPayload: ResolversUnionParentTypes['BookPayload'];
    };
  • f104619ac Thanks @​saihaj! - Resolve issue with nesting fields in @provides directive being prevented

  • Updated dependencies [e56790104, b7dacb21f, f104619ac, 92d86b009, acb647e4e, 9f4d9c5a4]:


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the release:chore This PR is a chore (means nothing for users) label Apr 4, 2023
@replay-io
Copy link

replay-io bot commented Apr 4, 2023

16 replays were recorded for 8d3cb07.

image 0 Failed
image 16 Passed
    requireAuth graphql checks
          ```
          locator.waitFor: Target closed
          =========================== logs ===========================
          waiting for locator('.rw-form-error-title').locator('text=You don\'t have permission to do that') to be visible
          ============================================================
          ```
        </ol>
      </details>
      <li><a href=https://app.replay.io/recording/fb2216b0-8d63-4c74-b34e-eac5e4c5076f>useAuth hook, auth redirects checks</a></li>
      <li><a href=https://app.replay.io/recording/e020c89b-0d29-40e9-b4d1-8c78ac4e64bc>Check that a specific blog post is prerendered</a></li>
      <li><a href=https://app.replay.io/recording/bc24a28d-2e33-428e-b401-76050982989d>Check that about is prerendered</a></li>
      <li><a href=https://app.replay.io/recording/fed2529f-621a-48ef-9432-9c0dded7962d>Check that homepage is prerendered</a></li>
      <li><a href=https://app.replay.io/recording/40ce0dfc-fe7e-4fce-ac8d-f01014549a98>Check that meta-tags are rendering the correct dynamic data</a></li>
      <li><a href=https://app.replay.io/recording/d866ab6f-887f-4e10-a694-4a46594d454a>Check that you can navigate from home page to specific blog post</a></li>
      <li><a href=https://app.replay.io/recording/12f7935e-ce3d-41e2-a14f-197dbbb8e296>Waterfall prerendering (nested cells)</a></li>
      <li><a href=https://app.replay.io/recording/67ef22a6-7a75-49ee-8556-65cb2eab614b>RBAC: Admin user should be able to delete contacts</a></li>
      <li><a href=https://app.replay.io/recording/765ac36c-ad51-471a-a6d4-741e2646bbdd>RBAC: Should not be able to delete contact as non-admin user</a></li>
      <li><a href=https://app.replay.io/recording/bea90f4f-c947-426c-9158-afe1c15c805b>Smoke test with dev server</a></li>
      <li><a href=https://app.replay.io/recording/9a750c39-f59a-4e05-b97a-0b7f439e9487>Smoke test with rw serve</a></li>
      <li><a href=https://app.replay.io/recording/2c257a21-95ea-44cb-a7fb-95300743b6cf>Loads Cell mocks when Cell is nested in another story</a></li>
      <li><a href=https://app.replay.io/recording/9da74b1c-cd04-44a9-a35b-abf64467eb2f>Loads Cell Stories</a></li>
      <li><a href=https://app.replay.io/recording/30418d81-8a73-4295-940d-cc99707ae9ae>Loads MDX Stories</a></li>
      <li><a href=https://app.replay.io/recording/9e14e9d5-b11a-49e0-9941-d17efa2e12c0>Mocks current user, and updates UI while dev server is running</a></li>
      

View test run on Replay ↗︎

@renovate renovate bot force-pushed the renovate/graphqlcodegenerator-monorepo branch from 905aaa1 to dc56ba3 Compare April 4, 2023 22:30
@renovate
Copy link
Contributor Author

renovate bot commented Apr 5, 2023

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

Warning: custom changes will be lost.

@jtoar jtoar merged commit 05c9257 into main Apr 26, 2023
@jtoar jtoar deleted the renovate/graphqlcodegenerator-monorepo branch April 26, 2023 03:07
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Apr 26, 2023
@jtoar jtoar modified the milestones: next-release, v5.0.0 Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:chore This PR is a chore (means nothing for users)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant