nicolasdao / graphql-s2s

Add GraphQL Schema support for type inheritance, generic typing, metadata decoration. Transpile the enriched GraphQL string schema into the standard string schema understood by graphql.js and the Apollo server client.
Other
187 stars 15 forks source link

Error in making schemas #50

Open wizd opened 3 years ago

wizd commented 3 years ago

C:\tmp\gogo\node_modules\graphql-s2s\src\utilities.js:38 const escapeGraphQlSchema = (sch, cr='░', t=' ') => sch.replace(/[\n\r]+/g, cr).replace(/[\t\r]+/g, t).replace(/\s+/g, ' ') ^ TypeError: sch.replace is not a function at escapeGraphQlSchema (C:\tmp\gogo\node_modules\graphql-s2s\src\utilities.js:38:57) at extractGraphMetadata (C:\tmp\gogo\node_modules\graphql-s2s\src\graphmetadata.js:109:60) at removeGraphMetadata (C:\tmp\gogo\node_modules\graphql-s2s\src\graphmetadata.js:164:15) at getSchemaAST (C:\tmp\gogo\node_modules\graphql-s2s\src\graphqls2s.js:1147:34) at transpile (C:\tmp\gogo\node_modules\graphql-s2s\src\graphqls2s.js:1154:15) at Object. (C:\tmp\gogo\src\graphql.ts:15:14) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Module.m._compile (C:\tmp\gogo\node_modules\ts-node\src\index.ts:1056:23) at Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Object.require.extensions. [as .ts] (C:\tmp\gogo\node_modules\ts-node\src\index.ts:1059:12) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object. (C:\tmp\gogo\src\index.ts:10:1) at Module._compile (internal/modules/cjs/loader.js:1063:30) Waiting for the debugger to disconnect... [nodemon] app crashed - waiting for file changes before starting...

my schemas:

export const DefaultSchema = `
  type Query {
    _empty: String
  }

  type Mutation {
    _empty: String
  }
`;

export const BlockTypes = `
  enum BlockTypes {
    Null
    Service
    Consolidation
    Sync
}
`;
export const BlockSchema = `
  scalar Date
  scalar JSON

  type Block {
    id: ID!
    Hash: String!
    Height: Int!
    TimeStamp: Date!
    Version: Int!
    BlockType: BlockTypes!
    PreviousHash: String
    ServiceHash: String
    Tags: JSON
  }
`;
export const schema = [DefaultSchema, BlockTypes, BlockSchema];
wizd commented 3 years ago

ok, found that I should not use array.

export const schema = DefaultSchema + BlockTypes + BlockSchema;