xstate-viz
                                
                                
                                
                                    xstate-viz copied to clipboard
                            
                            
                            
                        Module not found: Can't resolve './graphql/GetLoggedInUserData.generated'
Description
yarn install
npm start
Actual Result
[start:app] error - ./src/authMachine.ts:13:0
[start:app] Module not found: Can't resolve './graphql/GetLoggedInUserData.generated'
[start:app]   11 | } from 'xstate';
[start:app]   12 | import { createModel } from 'xstate/lib/model';
[start:app] > 13 | import {
[start:app]   14 |   GetLoggedInUserDataDocument,
[start:app]   15 |   GetLoggedInUserDataQuery,
[start:app]   16 |   LoggedInUserFragment,
[start:app]
[start:app] Import trace for requested module:
[start:app] ./src/pages/_app.tsx
[start:app]
                                    
                                    
                                    
                                
@qingmingsang Is this the only error you're seeing in the terminal? npm start runs the graphql-codegen script, which would generate these files.
@mattpocock This is the first obstructive error.
@qingmingsang Because there are multiple processes happening at the same time, the 'first' error may not be the most important. Can you have a deeper look in the terminal output and check for any other errors, particularly from the graphql:codegen process?
@mattpocock
This is all my terminal information:
➜  xstate-viz-dev npm start
> [email protected] start /Users/xstate-viz-dev
> concurrently "npm:start:app" "npm:graphql:codegen"
[start:app] npm run start:app exited with code SIGINT
[graphql:codegen]
[graphql:codegen] > [email protected] graphql:codegen /Users/xstate-viz-dev
[graphql:codegen] > graphql-codegen --watch
[graphql:codegen]
[start:app]
[start:app] > [email protected] start:app /Users/xstate-viz-dev
[start:app] > next
[start:app]
[start:app] ready - started server on 0.0.0.0:3000, url: http://localhost:3000
[start:app] info  - Loaded env from /Users/xstate-viz-dev/.env.development
[start:app] info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
[graphql:codegen] [17:50:57] Parse configuration [started]
[graphql:codegen] [17:50:57] Parse configuration [completed]
[graphql:codegen] [17:50:57] Generate outputs [started]
[graphql:codegen] [17:50:57] Generate src/graphql/schemaTypes.generated.ts [started]
[graphql:codegen] [17:50:57] Generate to src/graphql/ (using EXPERIMENTAL preset "near-operation-file") [started]
[graphql:codegen] [17:50:57] Load GraphQL schemas [started]
[graphql:codegen] [17:50:57] Load GraphQL schemas [started]
[start:app] error - ./src/authMachine.ts:13:0
[start:app] Module not found: Can't resolve './graphql/GetLoggedInUserData.generated'
[start:app]   11 | } from 'xstate';
[start:app]   12 | import { createModel } from 'xstate/lib/model';
[start:app] > 13 | import {
[start:app]   14 |   GetLoggedInUserDataDocument,
[start:app]   15 |   GetLoggedInUserDataQuery,
[start:app]   16 |   LoggedInUserFragment,
[start:app]
[start:app] Import trace for requested module:
[start:app] ./src/pages/_app.tsx
[start:app]
[start:app] https://nextjs.org/docs/messages/module-not-found
                                    
                                    
                                    
                                
@qingmingsang And no output after this? Strange. Since it has to load the schema over the internet, it might be taking a while where you are?
@mattpocock
Maybe because I'm in China? But I have vpn enabled and it still doesn't work
@qingmingsang Here is the full schema for the API.
If you save this file locally, then inside codegen.yml change https://api-dev.stately.ai to the location you've saved the file: ./my-file.gql.
This is graphql-codegen we're using:
https://www.graphql-code-generator.com/
This will stop network connection being an issue.
### This file was generated by Nexus Schema
### Do not make changes to this file directly
scalar Datetime
type Error {
  code: String!
  message: String!
}
enum GetSourceFilesOrderBy {
  likesCount
  updatedAt
}
enum GetSystemsOrderBy {
  likesCount
  updatedAt
}
input InviteTeamMembersInput {
  email: String!
  role: TeamMembershipRole!
}
type InviteTeamMembersResult {
  email: String!
  error: Error
  wasSuccessful: Boolean!
}
"""
The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
scalar JSONObject
  @specifiedBy(
    url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf"
  )
type Machine {
  """
  Return a JSON-serialisable machine config you can use with XState
  """
  asXStateMachineConfig: JSONObject!
  createdAt: Datetime!
  definition: JSONObject!
  """
  The machine this was forked from
  """
  forkParent: Machine
  forkParentId: String
  id: String!
  linkedMachines: [Machine!]!
  name: String!
  system: System!
  systemId: String!
  updatedAt: Datetime!
}
type Mutation {
  acceptInvitationToTeam(teamId: String!): TeamInvitation!
  addLike(sourceFileId: String!): SourceFile!
  addLikeToSystem(systemId: String!): System!
  createMachine(
    definition: JSONObject!
    forkParentId: String
    name: String!
    systemId: String!
  ): Machine!
  createSourceFile(
    description: String
    keywords: [String!]
    name: String
    text: String!
  ): SourceFile!
  createSystem(
    description: String
    forkParentId: String
    keywords: [String!]
    name: String!
    teamId: String
  ): System!
  createTeam(hidden: Boolean!, name: String!): Team!
  deleteMachine(id: String!): Machine!
  deleteSourceFile(id: String!): SourceFile!
  deleteSystem(id: String!): System!
  forkSourceFile(
    description: String
    forkFromId: String!
    keywords: [String!]
    name: String
    text: String!
  ): SourceFile!
  inviteTeamMembers(
    teamId: String!
    teamMembers: [InviteTeamMembersInput!]!
  ): [InviteTeamMembersResult!]!
  rejectInvitationToTeam(teamId: String!): TeamInvitation!
  removeLike(sourceFileId: String!): SourceFile
  removeLikeFromSystem(systemId: String!): System!
  updateMachine(definition: JSONObject, id: String!, name: String): Machine!
  updateSelfUser(avatarUrl: String, displayName: String): User!
  updateSourceFile(
    description: String
    id: String!
    keywords: [String!]
    name: String
    text: String
  ): SourceFile!
  updateSystem(
    description: String
    id: String!
    keywords: [String!]
    name: String
  ): System!
  updateTeam(hidden: Boolean, id: String!, name: String): Team!
}
"""
Only public-facing details of a user are held here
"""
type PublicUser {
  avatarUrl: String
  displayName: String
  id: String!
  sourceFiles(
    limit: Int!
    offset: Int!
    orderBy: GetSourceFilesOrderBy
    search: String
  ): [SourceFile!]!
  sourceFilesCount(search: String): Int!
  systems(limit: Int!, offset: Int!): [System!]!
  systemsCount: Int!
  teams(limit: Int!, offset: Int!): [Team!]!
  teamsCount: Int!
}
type Query {
  getLoggedInUser: User
  getMachine(id: String!): Machine
  getSourceFile(id: String!): SourceFile
  getSourceFiles(
    limit: Int!
    offset: Int!
    orderBy: GetSourceFilesOrderBy
    search: String
  ): [SourceFile!]!
  getSourceFilesCount(search: String): Int!
  getSystem(id: String!): System
  getSystems(limit: Int!, offset: Int!, search: String): [System!]!
  getSystemsCount(search: String): Int!
  getTeam(id: String!): Team
  getUser(id: String!): PublicUser
}
type SourceFile {
  createdAt: Datetime!
  description: String!
  """
  The source file this was forked from
  """
  forkParent: SourceFile
  forkParentId: String
  """
  The number of source files forked from this
  """
  forksCount: Int!
  id: String!
  keywords: [SourceFileKeyword!]!
  likesCount: Int!
  name: String!
  owner: PublicUser
  ownerId: String!
  system: System
  systemId: String
  text: String!
  updatedAt: Datetime!
  youHaveLiked: Boolean!
}
type SourceFileKeyword {
  text: String!
}
type System {
  createdAt: Datetime!
  description: String
  """
  The system this was forked from
  """
  forkParent: System
  forkParentId: String
  id: String!
  keywords: [SourceFileKeyword!]!
  machines(limit: Int!, offset: Int!): [Machine!]!
  machinesCount: Int!
  name: String!
  owner: PublicUser
  ownerId: String!
  sourceFile: SourceFile
  team: Team
  teamId: String
  updatedAt: Datetime!
  youCanEdit: Boolean!
  youHaveLiked: Boolean!
}
type Team {
  hidden: Boolean!
  id: String!
  members(limit: Int!, offset: Int!): [TeamMembership!]!
  membersCount: Int!
  name: String!
  systems(limit: Int!, offset: Int!): [System!]!
  systemsCount: Int!
}
type TeamInvitation {
  id: String!
  team: Team
  teamId: String!
}
type TeamMembership {
  role: TeamMembershipRole!
  team: Team
  teamId: String!
  user: PublicUser
  userId: String!
}
enum TeamMembershipRole {
  admin
  basic
}
type User {
  avatarUrl: String
  displayName: String
  email: String!
  favouriteSystems(limit: Int!, offset: Int!): [System!]!
  favouriteSystemsCount: Int!
  hasBetaSubscription: Boolean!
  id: String!
  invitationsToTeams(limit: Int!, offset: Int!): [TeamInvitation!]!
  invitationsToTeamsCount: Int!
  sourceFiles(
    limit: Int!
    offset: Int!
    orderBy: GetSourceFilesOrderBy
    search: String
  ): [SourceFile!]!
  sourceFilesCount(search: String): Int!
  systems(limit: Int!, offset: Int!): [System!]!
  systemsCount: Int!
  teams(limit: Int!, offset: Int!): [Team!]!
  teamsCount: Int!
}