acro5piano / graphql-rest-proxy

Turn your REST API into GraphQL - A Proxy Server that pipes request from GraphQL to REST with GraphQL DSL, performant nested children, mutations, input types, and more.

Home Page:https://www.npmjs.com/package/graphql-rest-proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Cannot read schema file" with a seemingly valid graphql schema

mathieucaroff opened this issue · comments

It happens both on Windows 10 and WSL Ubuntu 18.04. It also happens no matter whether I use npm i -g, yarn global add or npx to install and run it.

C:\gd(master -> origin) (sgq@1.0.0)
$ npm i -g graphql-rest-proxy
C:\Program Files\nodejs\graphql-rest-proxy -> C:\Program Files\nodejs\node_modules\graphql-rest-proxy\dist-node\index.bin.js
+ graphql-rest-proxy@0.4.1
added 163 packages from 105 contributors in 8.756s

C:\gd(master -> origin) (sgq@1.0.0)
$ graphql-rest-proxy src/schema.gql
npx: installed 163 in 11.153s
Cannot read schema file: C:\gd\derpibooru-graphql\src\schema.gql

C:\gd(master -> origin) (sgq@1.0.0)
$ graphql-rest-proxy --version
0.4.1

Here is schema.gql:

type Query {
    image(id: ID): Image @proxy(get: "/:id.json")
    user(name: ID): User @proxy(get: "/profiles/:name.json")
    search(
        query: String!
        sort: SortFieldInput = created_at
        order: SortOrderInput = desc
    ): SearchPage! @proxy(get: "/search?q=:query&sf=:sort&sd=:sort_order")
}

scalar CommaSpaceSeparatedString
scalar Date
scalar Extension
scalar Mime
scalar Sha512
scalar Url

enum UserRole {
    user
}

enum InteractionType {
    voted
    faved
}

enum InteractionValue {
    up
    down
}

enum SortFieldInput {
    created_at
    updated_at
    first_seen_at
    score
    wilson
    relevance
    width
    height
    comments
    tag_count
    random
}

enum SortOrderInput {
    asc
    desc
}

type Image {
    aspect_ratio: Float!
    comment_count: Int!
    created_at: Date!
    description: String
    downvotes: Int!
    faves: Int!
    file_name: String
    first_seen_at: Date
    height: Int!
    id: ID!
    image: Url
    interactions: [Interaction!]!
    is_optimized: Boolean!
    is_rendered: Boolean!
    mime_type: Mime
    orig_sha512_has: Sha512
    original_format: Extension
    representations: Representations
    score: Int!
    sha512_hash: Sha512
    source_url: Url
    spoilered: Boolean
    tag_ids: [ID!]!
    tags: CommaSpaceSeparatedString
    updated_at: Date!
    uploader_id: Int
    uploader: String
    uploader_info: User @proxy(get: "/profiles/:uploader.json")
    upvotes: Int!
    width: Int!
}

type Interaction {
    id: ID
    image_id: ID
    image: Image @proxy(get: "/:image_id.json")
    interaction_type: InteractionType
    user_id: ID
    user: User @proxy(get: "/profiles/:user_id.json")
    value: InteractionValue
}

type Representations {
    thumb_tiny: Url
    thumb_small: Url
    thumb: Url
    small: Url
    medium: Url
    large: Url
    tall: Url
    full: Url
}

type SearchPage {
    search: [Image!]!
    total: Int!
    interactions: [Interaction!]!
}

type User {
    avatar_url: Url
    awards: [String!]!
    comment_count: Int!
    created_at: Date!
    description: String
    id: ID
    links: [String!]!
    name: String!
    post_count: Int!
    role: UserRole!
    slug: String!
    topic_count: Int!
    uploads_count: Int!
}

Hi, thank you for reporting.
I haven't tested it on Windows, but it is working on my Mac correctly. Could you clone this repository and try the following command in root directory?

graphql-rest-proxy  -c examples/proxy.config.js --port 5252 examples/schema.graphql

It appears I did my test wrong with examples/schema.graphql. It actually works, both on Windows and on Linux. However, the first GraphQL file content I brought still provokes the Cannot read schema file error message.

I'll try to narrow my example, and see how I can make it minimal.

Thank you.

Closing due to no activity. Feel free to reopen it.