Code Monkey home page Code Monkey logo

graphql-mesh's Introduction

Mesh GIF

npm version CI Discord Chat code style: prettier

https://www.graphql-mesh.com

GraphQL Mesh allows you to use GraphQL query language to access data in remote APIs that don't run GraphQL (and also ones that do run GraphQL). It can be used as a gateway to other services or run as a local GraphQL schema that aggregates data from remote APIs.

The goal of GraphQL Mesh is to let developers easily access services that are written in other APIs specs (such as gRPC, OpenAPI/Swagger, OData, SOAP/WSDL, Apache Thrift, Mongoose, PostgreSQL, Neo4j, and also GraphQL) with GraphQL queries and mutations.

GraphQL Mesh gives the developer the ability to modify the output schemas, link types across schemas and merge schema types. You can even add custom GraphQL types and resolvers that fit your needs.

It allows developers to control the way they fetch data, and overcome issues related to backend implementation, legacy API services, chosen schema specification and non-typed APIs.

GraphQL Mesh is acting as a proxy to your data, and uses common libraries to wrap your existing API services. You can use this proxy locally in your service or application by running the GraphQL schema locally (with GraphQL execute), or you can deploy this as a gateway layer to your internal service.

How does it work?

The way GraphQL Mesh works is:

  1. Collect API schema specifications from services
  2. Create a runtime instance of fully-typed SDK for the services.
  3. Convert API specs to GraphQL schema
  4. Applies custom schema transformations and schema extensions
  5. Creates fully-typed, single schema, GraphQL SDK to fetch data from your services.

Getting Started

Installation

GraphQL Mesh comes in multiple packages, which you should install according to your needs.

To get started with the basics, install the following:

$ yarn add graphql @graphql-mesh/runtime @graphql-mesh/cli

Then, you need to install a Mesh handler, according to your API needs. You can see the list of all available built-in handlers in this README, under the Supported APIs section.

For example, if you wish to use OpenAPI handler, install the handler that matches your needs:

$ yarn add graphql @graphql-mesh/openapi

Then, this handler will be available for you to use in your config file.

Getting started

Supported Source APIs

Schema Transformations

Contributions

Contributions, issues and feature requests are very welcome. If you are using this package and fixed a bug for yourself, please consider submitting a PR!

And if this is your first time contributing to this project, please do read our Contributor Workflow Guide before you get started off.

Code of Conduct

Help us keep GraphQL Mesh open and inclusive. Please read and follow our Code of Conduct as adopted from Contributor Covenant

License

GitHub license

MIT

graphql-mesh's People

Contributors

ardatan avatar charlypoly avatar cometkim avatar cweckesser avatar dependabot[bot] avatar devsergiy avatar dimamachina avatar dotansimha avatar dr3 avatar emrysmyrddin avatar enisdenjo avatar germankrause avatar gilgardosh avatar github-actions[bot] avatar habbes avatar kamilkisiela avatar mhassan1 avatar nemonemi avatar ntziolis avatar pagebakers avatar playanydata avatar renovate-bot avatar renovate[bot] avatar rufman avatar santino avatar soerenuhrbach avatar theguild-bot avatar tuvalsimha avatar tvvignesh avatar urigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-mesh's Issues

parseConfig should optionally accept an object, instead of reading from the filesystem

I'm currently trying to deploy GraphQL Mesh on @zeit Now as a Next.js API route. No matter where I place the .meshrc.yaml, it can't be found.

[POST] /api/mesh

2020-03-27T05:53:20.824Z	b1b51018-01d9-45ad-886e-1b114097e663	ERROR	TypeError: Cannot read property 'require' of undefined    at parseConfig (/var/task/node_modules/@graphql-mesh/runtime/dist/parse-config.js:25:16)    at async module.exports.vbkO.__webpack_exports__.default (/var/task/.next/serverless/pages/api/mesh.js:283:84)    at async apiResolver (/var/task/node_modules/next/dist/next-server/server/api-utils.js:48:9)

I also tried to deploy it out as a standalone function on @zeit Now and even when I could confirm the file was present, it still couldn't find the config.

[POST] /api/mesh

.meshrc.json
mesh.js
mesh.js.map

2020-03-27T14:38:38.136Z	504307a5-1c46-4f80-816d-95ea581ec08f	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'require' of undefined","reason":{"errorType":"TypeError","errorMessage":"Cannot read property 'require' of undefined","stack":["TypeError: Cannot read property 'require' of undefined","    at parseConfig (/var/task/node_modules/@graphql-mesh/runtime/dist/parse-config.js:25:16)","    at _default (/var/task/api/mesh.js:22:61)","    at Server.<anonymous> (/var/task/___now_helpers.js:869:13)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'require' of undefined","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:323:22)","    at process.emit (/var/task/__sourcemap_support.js:2535:21)","    at processPromiseRejections (internal/process/promises.js:209:33)","    at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
Unknown application error occurred

It would be helpful for serverless scenarios to allow passing the config object into parseConfig directly. This would also enable the use of ENV_VARS for secrets, such as API Keys.

Parameters with non-latin names getting lost

Hi,
I'm working on an API using hebrew names to some of its parameters.
when I suppose to receive a json object with some hebrew-named parameters, they got lost somewhere in the mesh process.

for example, expected to receive:

    {
        "מספר רץ": 1,
        "חשבון חובה ראשי": "30001",
        "חשבון זכות ראשי": "40001",
        "שם חשבון חובה": "כיתנס",
        "שם חשבון זכות": "הכנסות ממכירה בארץ - כולל מעמ",
        "פרטים": "חשבונית",
        "אסמכתא 1": 0,
        "אסמכתא 2": 0,
        "סוג תנועה": "חל",
        "מטבע": "$",
        "תאריך": "2018-03-25T22:00:00.000Z",
        "תאריך ערך": "2018-03-25T22:00:00.000Z",
        "קוד תמחיר": null,
        "סה&quot;כ שקל בתנועה": 100,
        "סה&quot;כ מט&quot;ח בתנועה": 0,
        "אסמכתא 3": 0,
        "תאריך 3": "2018-03-25T22:00:00.000Z",
        "כמות": 0,
        "סניף": 1,
        "הערות": null,
        "הערות נוספות": null,
        "מספר עוסק מורשה": "",
        "מספר מנה": 1,
        "פרטי מנה": "תנועות בנק וחשבוניות",
        "שעת פתיחת המנה": null,
        "תאריך פתיחת המנה": "1999-03-21T22:00:00.000Z"
    }

but got:

{
_: '2018-03-25T22:00:00.000Z',
_1: 0,
_2: 0,
quot: 100,
quotQuot: 0,
_3: '2018-03-25T22:00:00.000Z'
}

Authentication with openapi not passing

Hi,

Our project management tool called YouTrack supports the openapi v3 standard but it requires authentication. I am having some trouble authenticating ... or so I believe.

Executing the curl request below returns the desidered output (See the attached zip file openapi.json.zip)

curl --location --request GET 'https://youtrack.example.com/api/openapi.json' \
--header 'Authorization: Bearer perm:******************'

My .meshrc.yaml

sources:
  - name: Youtrack
    handler:
      openapi:
        source: https://youtrack.example.com/api/openapi.json
        headers:
          Authorization: Bearer Bearer perm:******************

Then when I execute yarn graphql-mesh serve it results in

error: Unable to serve mesh: Invalid specification provided {"stack":"Error: Invalid specification provided\n    at Object.<anonymous> (/Users/garethhall/Sites/communica/taskhub/node_modules/openapi-to-graphql/lib/oas_3_tools.js:61:19)\n    at Generator.next (<anonymous>)\n    at /Users/garethhall/Sites/communica/taskhub/node_modules/openapi-to-graphql/lib/oas_3_tools.js:12:71\n    at new Promise (<anonymous>)\n    at __awaiter (/Users/garethhall/Sites/communica/taskhub/node_modules/openapi-to-graphql/lib/oas_3_tools.js:8:12)\n    at Object.getValidOAS3 (/Users/garethhall/Sites/communica/taskhub/node_modules/openapi-to-graphql/lib/oas_3_tools.js:41:12)\n    at Object.<anonymous> (/Users/garethhall/Sites/communica/taskhub/node_modules/openapi-to-graphql/lib/index.js:96:37)\n    at Generator.next (<anonymous>)\n    at /Users/garethhall/Sites/communica/taskhub/node_modules/openapi-to-graphql/lib/index.js:12:71\n    at new Promise (<anonymous>)"}

Finally, I saved the contents of https://youtrack.example.com/api/openapi.json to a file and updated .meshrc.yaml with the source pointing to source: ./openapi.json which then allows me to run yarn graphql-mesh serve Playground is accessible, schema, queries, mutation and everything seems to be there. Obviously executing queries does not work since the real host is not being piped through.

So am I doing something wrong or is there an issue with authentication?

@graphql-mesh/json-schema not accepting JSON schema formatted from an API response

Hi there!
I love the idea and excited to get this working as it is intended.

I'm trying out @graphql-mesh/json-schema.
My goal is to expose a graphQL endpoint for the existing REST enpoint.
I've made the API call and saved the response.
At first, I was naive and thought I could just save the response JSON and point the .meshrc.yaml at it, but of course, it's not a valid JSON schema.
I Tried converting said response with https://www.jsonschema.net/ and https://www.liquid-technologies.com/online-json-to-schema-converter but when trying to run graphql-mesh serve i get an Unexpected schema definition and Cannot use 'in' operator to search for 'definitions' in undefined
Is there any way to get a more clear error or provide an example of how to go about doing something similar?

package.json:

"dependencies": {
    "@graphql-mesh/cli": "^0.1.4",
    "@graphql-mesh/json-schema": "^0.1.4",
    "@graphql-mesh/runtime": "^0.1.4",
    "graphql": "^15.0.0",
  }

This is the .meshrc.yaml (endpoint extracted, paths are correct):

sources:
  - name: Some API
    handler:
      jsonSchema:
        baseUrl: https://base-url.com
        operations:
          - type: Query
            field: article
            path: /articles/slug/{args.slug}
            method: GET
            responseSchema: ./mesh-schema/json-schemas/article.json

Error:

error: Unable to serve mesh: Cannot use 'in' operator to search for 'definitions' in undefined {"stack":"TypeError: Cannot use 'in' operator to search for 'definitions' in undefined\n    at JSONSchemaVisitor.visit (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:42:27)\n    at JSONSchemaVisitor.visitArray (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:91:45)\n    at JSONSchemaVisitor.visit (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:56:29)\n    at JSONSchemaVisitor.createFieldsMapFromProperties (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:147:31)\n    at JSONSchemaVisitor.getGraphQLObjectTypeWithTypedObjectDef (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:207:34)\n    at JSONSchemaVisitor.visitTypedUnnamedObjectDefinition (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:224:21)\n    at JSONSchemaVisitor.visit (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:80:33)\n    at JSONSchemaVisitor.createFieldsMapFromProperties (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:147:31)\n    at JSONSchemaVisitor.getGraphQLObjectTypeWithTypedObjectDef (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:207:34)\n    at JSONSchemaVisitor.visitTypedUnnamedObjectDefinition (/Users/yoavganbar/projects/learn/graphql-udemy/node_modules/@graphql-mesh/json-schema/index.cjs.js:224:21)"}

running with npm

openapi handler fails to parse swagger schema from Java service

Having that endpoint definition from Java Spring service (a part of schema)

"/trendchart": {
"get": {
"tags": [
"trend-chart-rest-controller"
],
"summary": "getTrendChartLight",
"operationId": "getTrendChartLightUsingGET_1",
"produces": [
"application/json;charset=UTF-8"
],
"parameters": [
{
"name": "ClientId",
"in": "header",
"description": "OAuth Client Id",
"required": true,
"type": "string",
},
{
"name": "allRequestParams",
"in": "query",
"description": "allRequestParams",
"required": true,
"items": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ResponseEntity«object»"
}
},
"500": {
"description": "Internal Server Error"
}
},
"security": [
{
"OAuth Scheme": [
"read",
"write"
]
}
],
"deprecated": false
}
}

In some cases the definition reference is ReponseEntity<Model>
Schema is automatically generated.

Having an error
S2OError: Could not resolve reference #/definitions/ResponseEntity«object» at throwError (E:\projects\hasura-mesh\node_modules\swagger2openapi\index.js:39:15) at throwOrWarn (E:\projects\hasura-mesh\node_modules\swagger2openapi\index.js:54:9) at fixupRefs (E:\projects\hasura-mesh\node_modules\swagger2openapi\index.js:222:17)

I assume that ResponseEntity is as Spring class and it is not present in swagger schema.

Postgres session need to be closed after request (`postgraphile`)

We are not using the context builder of postgraphile, because it's not super easy to integrate it with a non-http environment (as far as I remember). So at the moment the connection is not being releases.

I think we can add hooks for that, and release it after execution is done.

Allow "whitelisting" endpoints for schema generation

Using the OpenAPI generator, I would like to limit the endpoints exposed in the generated GraphQL schema. This will allow me to filter out the noise of hundreds of queries that we dont use in our application, and also helps prevent people from querying endpoints we dont want them to query.

Wrapping data source abstraction?

Things like:

  • DataLoader Optimization
  • Predefined caching
  • Custom caching mechanism
  • Mocking
  • Snapshot for local development
  • more?
  • Allow it per operation?

Typescript: compilation fails when strict type checking option `noUnusedParameters` is set to true

Given you choose strict type checking in your tsconfig.json, more precisely set the option noUnusedParameters to true, the compilation fails due to unused parameters in the dependency tsargs.

node_modules/tsargs/lib/pre-argn.ts:210:134 - error TS6133: 'A' is declared but its value is never read. 210 T extends (pre1: Pre1, pre2: Pre2, pre3: Pre3, pre4: Pre4, pre5: Pre5, pre6: Pre6, pre7: Pre7, pre8: Pre8, arg1: infer A, arg2: infer B, arg3: infer C, arg4: infer D, arg5: infer E) => any ? 

Incorrectly identified content type for openapi endpoint

I have openapi endpoint which returns response with Content-Type set to "application/json;charset=UTF-8".
readUrl function fails to test content type with regex /json$/.test(contentType) as it expects it to be at the end of the string

Support JSON Schema as input schemas

We can support JSON Schema structure for request-response, it might be a bit more tricky since it requires us to have more explicit declaration in the YAML config file.

Example:

sources:
  - name: Offers
    handler:
      name: json-schema
      config: 
        baseUrl: http://something/
        operations:
          - type: Query
            field: availableOffers
            path: /offers/available-offers
            method: GET
            requestSchema: request.json
            responseSchema: response.json

Throws "Could not invoke operation" error in openapi to graphql resolver builder

Hi,

I am experiencing the following issue when testing the stripe API using version 0.0.21-alpha-d20fcf0.20+d20fcf0. My .meshrc.yaml looks like this

sources:
  - name: Stripe
    handler:
      openapi:
        source: https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec2.yaml
        baseUrl: https://api.stripe.com
        operationHeaders:
          Authorization: "Bearer *********

When running the below query, I receive the error Could not invoke operation <...>.

Query

query {
  getBalance {
    available {
      amount
      currency
    }
  }
}

Response

{
  "errors": [
    {
      "message": "Could not invoke operation GET /v1/balance",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "getBalance"
      ],
      "extensions": {
        "method": "get",
        "path": "/v1/balance",
        "statusCode": 400,
        "responseHeaders": {
          "connection": "close",
          "content-length": "150",
          "content-type": "text/html",
          "date": "Sun, 12 Apr 2020 11:11:47 GMT",
          "server": "nginx",
          "strict-transport-security": "max-age=31556926; includeSubDomains; preload"
        },
        "responseBody": "<html>\r\n<head><title>400 Bad Request</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n",
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "message": "Could not invoke operation GET /v1/balance",
          "stacktrace": [
            "GraphQLError: Could not invoke operation GET /v1/balance",
            "    at graphQLErrorWithExtensions (<...>/node_modules/@ardatan/openapi-to-graphql/lib/resolver_builder.js:719:12)",
            "    at <...>/node_modules/@ardatan/openapi-to-graphql/lib/resolver_builder.js:280:23",
            "    at Generator.next (<anonymous>)",
            "    at fulfilled (<...>/node_modules/@ardatan/openapi-to-graphql/lib/resolver_builder.js:9:58)",
            "    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
          ]
        }
      }
    }
  ],
  "data": {
    "getBalance": null
  }
}

Looking at the stripe logs, the request doesn't hit their servers. I have tested the same query with the IBM/openapi-to-graphql lib by running openapi-to-graphql https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec2.yaml --header Authorization:Bearer\ ********* and that seems to behave as expected.

Subscription issue with grpc-example

With a clean pull of the repo and running the example using yarn start I am receiving the error message below when running the query

Query

subscription {
  ExampleSearchMoviesByCast(SearchByCastInput:{
    castName:"Tom Cruise"
  }) {
    name
    year
    rating
    cast
  }
}

Error

/workspace/graphql-mesh/examples/grpc-example/node_modules/grpc-graphql-schema/lib/service_converter.js:114
                    pubsub.publish(`${methodName}-onSubscribe`, payload);
                           ^

TypeError: Cannot read property 'publish' of undefined
    at ClientReadableStream.response.on (/workspace/graphql-mesh/examples/grpc-example/node_modules/grpc-graphql-schema/lib/service_converter.js:114:28)
    at ClientReadableStream.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at ClientReadableStream.Readable.push (_stream_readable.js:224:10)
    at Object.onReceiveMessage (/workspace/graphql-mesh/examples/grpc-example/node_modules/grpc/src/client_interceptors.js:1263:19)
    at InterceptingListener.recvMessageWithContext (/workspace/graphql-mesh/examples/grpc-example/node_modules/grpc/src/client_interceptors.js:607:19)
    at /workspace/graphql-mesh/examples/grpc-example/node_modules/grpc/src/client_interceptors.js:707:14
error Command failed with exit code 1.

Unexpected content-type error in swagger/openAPI query response

I'm trying this mesh in one of our client swagger micro-services:
I am able to run the serve cli command and get graphiql running with everything documented.

Running a query I get the following error:
"Unexpected error value: \"Operation GET /api/v1/transfers/address/accountId={accountId} should have a content-type '*/*' but has 'application/json;charset=UTF-8' instead\"",

I want to assume this is a swagger bug as its specifying that it will return '/' but instead it returns other content-types.
Is there a way to bypass this?

'core-js/modules/es6.array.find' cannot be used with the json-schema API

hi. I'm having a bit of trouble, so let me share.

To load the json-schema, I wrote the following in .meshrc.yaml

sources:
  - name: qiita
    handler:
      json-schema:
        source: https://qiita.com/api/v2/schema

package.json is as follows

{
  "dependencies": {
    "@graphql-mesh/cli": "^0.0.16",
    "@graphql-mesh/json-schema": "^0.0.16",
    "@graphql-mesh/openapi": "^0.0.16",
    "@graphql-mesh/runtime": "^0.0.16",
    "graphql": "^14.6.0"
  }
}

And when I try to start the graphql-mesh server, I get an error like the following

$ yarn graphql-mesh serve
yarn run v1.22.4
warning package.json: No license field
$ /Users/daisuke/work/tttt/node_modules/.bin/graphql-mesh serve
error: Unable to serve mesh: Unable to load handler matching json-schema: Cannot find module 'core-js/modules/es6.array.find'
Require stack:
- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/Interpolator.js
- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/index.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/json-schema/dist/index.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/utils.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/get-mesh.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/index.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/cli/dist/bin.js {"stack":"Error: Unable to load handler matching json-schema: Cannot find module 'core-js/modules/es6.array.find'\nRequire stack:\n- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/Interpolator.js\n- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/index.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/json-schema/dist/index.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/utils.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/get-mesh.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/index.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/cli/dist/bin.js\n    at getPackage (/Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/utils.js:51:23)"}
✨  Done in 3.05s.

To fix this, I decided to install an older version of core-js.

{
  "dependencies": {
    "@graphql-mesh/cli": "^0.0.16",
    "@graphql-mesh/json-schema": "^0.0.16",
    "@graphql-mesh/openapi": "^0.0.16",
    "@graphql-mesh/runtime": "^0.0.16",
    "core-js": "^2.6.2",           // <------ add it.
    "graphql": "^14.6.0"
  }
}

I think we need to resolve these library dependencies.

Typescript: generating invalid typings

Hi there,

when attempting to create typings from the stripe OpenAPI Spec it creates invalid typings, both, for version 2 and 3.

The relevant block in spec version 2 is the following.

account_holder_type:
 description: The type of entity that holds the account. This can be either `individual` or `company`.
 enum:
 - ''
 - company
 - individual
 type: string

Running npx graphql-mesh typescript --output ./src/generated/mesh.ts generates the below typings.

export enum StripeAccountHolderType {
   = '_',
  Company = 'company',
  Individual = 'individual'
}

export enum StripeAccountHolderType2 {
  Company = 'company',
  Individual = 'individual'
}

export enum StripeAccountHolderType3 {
  Company = 'company',
  Individual = 'individual'
}

export enum StripeAccountHolderType4 {
  Company = 'company',
  Individual = 'individual'
}

Obviously, the enum StripeAccountHolderType does contain invalid syntax. Additionally, why does it create four enums representing the same type? Arguably, the account_holder_type enum in the OpenAPI spec contains an empty string, but in my opinion, the generation should aim to create only valid syntax.

Similar problems arise when using the spec version 3. Again, the types generated contain invalid syntax: An enum member cannot have a numeric name.

export enum StripeApiVersion {
  2011_01_01 = '2011-01-01',
  ...
}

For completeness, here is my .meshrc.yaml:

sources:
  - name: Stripe
    handler:
      openapi:
        source: https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.yaml
        baseUrl: https://api.stripe.com
        operationHeaders:
          Authorization: "Bearer <TOKEN>"
    transforms:
      - prefix:
          value: Stripe

Postgraphile won't serve: error: Unable to serve mesh: Cannot use GraphQLObjectType "Query" from another module or realm.

When I try to launch with a very simple postgraphile config (lifted directly from the example, just changed the connectionstring) I get the following error when trying to serve;

error: Unable to serve mesh: Cannot use GraphQLObjectType "Query" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

I checked my node_modules, but there aren't 2 versions of graphql installed.

To set up this project, I followed the basic tutorial and was able to run the example with the wikipedia API. I then installed @graphql-mesh/postgraphile and changed the .meshrc.yaml to the example given with another connectionString.

The server I am connecting to runs Postgres 9.6, which is listed as Officially Supported on the postgraphile project.

OpenAPI forward tenant header to API

Hi guys,

I'm trying to use GraphQL Mesh with a multi-tenant OpenApi 3.0. The OpenApi has a apiKey security scheme described as :

components:
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: X-Tenant-ID
      description: Tenant ID

In the GraphQL query I added headers (with Apollo Playground) :

{
  "X-Tenant-ID": "my-tenant-id"
}

But I can't figure out how to forward this header to the REAST Api. Is there any way yet ?

I noticed that the release 0.0.20 allows to add operationHeaders, so for the moment I can hardcode my tenant header.

sources:
  - name: My API
    handler:
      openapi:
        source: http://localhost:8080/api-docs/json
        operationHeaders:
          X-Tenant-ID: my-tenant-id
        baseUrl: http://localhost:8080     

Thanks for the amazing job guys !

No licence

Licence description is missing in project

getPackageProtoDefinition for proto file with mulitple namespaces

I'm trying to load a proto file that references google protobuf definitions amounts others. When generating the schema, the heal function removes all fields that have types like google.protobuf.StringValue because they resolve to undefined.

I think this happens because those type are never resolved from the proto. When you load the proto with protobufjs you do get all those types in the google namespace (on the nested attribute), but getFromObject only extract the namespace of the actual service defined, so you loose these definitions that are in these other namespaces.

I'm unsure how exactly to resolve this issue. Would an acceptable solution be to extract all namespaces and add these to the object returned from getPackageProtoDefinition?

Circularity Error With Tsconfig on Location-Weather Example

Hello there!

I've been working through the examples of GraphQL Mesh, trying to get everything up and running, as I'm writing an article on it. I've got nearly everything working now, but I wanted to offer a working example of merging APIs using the library. After I install all of the libraries and then try and serve the GraphQL Mesh, I get the following error:

error: Unable to serve mesh: ⨯ Unable to compile TypeScript:
error TS6053: File 'tsconfig.json' not found.
 {"diagnosticText":"\u001b[91merror\u001b[0m\u001b[90m TS6053: \u001b[0mFile 'tsconfig.json' not found.\r\n","diagnosticCodes":[6053],"stack":"TSError: ⨯ Unable to compile TypeScript:\n\u001b[91merror\u001b[0m\u001b[90m TS6053: \u001b[0mFile 'tsconfig.json' not found.\r\n\n    at createTSError (C:\\Users\\senorita\\Documents\\Projects\\location-weather\\node_modules\\ts-node\\src\\index.ts:421:12)\n    at reportTSError (C:\\Users\\senorita\\Documents\\Projects\\location-weather\\node_modules\\ts-node\\src\\index.ts:425:19)\n    at create (C:\\Users\\senorita\\Documents\\Projects\\location-weather\\node_modules\\ts-node\\src\\index.ts:436:36)\n    at Object.register (C:\\Users\\senorita\\Documents\\Projects\\location-weather\\node_modules\\ts-node\\src\\index.ts:334:19)\n    at Object.<anonymous> (C:\\Users\\senorita\\Documents\\Projects\\location-weather\\node_modules\\ts-node\\register\\transpile-only.js:1:16)\n    at Module._compile (internal/modules/cjs/loader.js:1158:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)\n    at Module.load (internal/modules/cjs/loader.js:1002:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:901:14)\n    at Module.require (internal/modules/cjs/loader.js:1044:19)"}
Done in 4.04s.

Anyone might be able to help me with this, by chance? Would be majorly, hugely appreciated! Thanks so much in advance!

js-wiki example does not work

graphql-mesh/examples/javascript-wiki on  master [?] is 📦 v0.0.15 via ⬢ v13.2.0
➜ npm run mesh:serve

> [email protected] mesh:serve /Users/isnifer/www/github/graphql-mesh/examples/javascript-wiki
> graphql-mesh serve

error: Unable to serve mesh: Request is not defined {"stack":"ReferenceError: Request is not defined\n    at readUrl (/Users/isnifer/www/github/graphql-mesh/examples/javascript-wiki/node_modules/@graphql-mesh/openapi/dist/index.js:54:54)\n    at Object.getMeshSource (/Users/isnifer/www/github/graphql-mesh/examples/javascript-wiki/node_modules/@graphql-mesh/openapi/dist/index.js:23:26)\n    at /Users/isnifer/www/github/graphql-mesh/examples/javascript-wiki/node_modules/@graphql-mesh/runtime/dist/get-mesh.js:13:55\n    at Array.map (<anonymous>)\n    at Object.getMesh (/Users/isnifer/www/github/graphql-mesh/examples/javascript-wiki/node_modules/@graphql-mesh/runtime/dist/get-mesh.js:12:39)\n    at Object.handler (/Users/isnifer/www/github/graphql-mesh/examples/javascript-wiki/node_modules/@graphql-mesh/cli/dist/bin.js:34:64)"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.