{"id":16061148,"url":"https://github.com/kbrandwijk/graphql-gateway-tools","last_synced_at":"2025-03-18T05:30:30.874Z","repository":{"id":57253450,"uuid":"109786466","full_name":"kbrandwijk/graphql-gateway-tools","owner":"kbrandwijk","description":"A set of tools to help you build a GraphQL Gateway using remote schemas and schema stitching.","archived":false,"fork":false,"pushed_at":"2017-11-15T03:26:55.000Z","size":27,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T01:33:24.669Z","etag":null,"topics":["apollo-server","graphql","graphql-gateway","remote-schemas","schema-stitching"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbrandwijk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-07T04:23:27.000Z","updated_at":"2020-01-29T20:49:17.000Z","dependencies_parsed_at":"2022-08-31T22:20:43.333Z","dependency_job_id":null,"html_url":"https://github.com/kbrandwijk/graphql-gateway-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrandwijk%2Fgraphql-gateway-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrandwijk%2Fgraphql-gateway-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrandwijk%2Fgraphql-gateway-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrandwijk%2Fgraphql-gateway-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbrandwijk","download_url":"https://codeload.github.com/kbrandwijk/graphql-gateway-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243672257,"owners_count":20328758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo-server","graphql","graphql-gateway","remote-schemas","schema-stitching"],"created_at":"2024-10-09T04:08:00.529Z","updated_at":"2025-03-18T05:30:30.430Z","avatar_url":"https://github.com/kbrandwijk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## UPDATE: `graphql-gateway-tools` has been abandoned in favor of my new GraphQL Application Framework: [Qewl](https://github.com/kbrandwijk/qewl)\n\n\n\n\n\n\n\n\n# graphql-gateway-tools\n\nA set of tools to help you build a GraphQL Gateway using remote schemas and schema stitching.\n\n[![https://nodei.co/npm/graphql-gateway-tools.png?downloads=false\u0026downloadRank=true\u0026stars=true](https://nodei.co/npm/graphql-gateway-tools.png?downloads=false\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/graphql-gateway-tools)\n\n## SchemaGenerator\n\nA higher order helper for creating a merged schema. It makes it easy to compose a schema, by providing methods to add remote schema endpoints, local GraphQL schemas, partial type definitions, and multiple resolver functions.\n\n```ts\nconst schemaGenerator = new SchemaGenerator()\n\n// Create a remoteExecutableSchema by specifying the endpoint address\nawait schemaGenerator.registerEndpoint({uri: 'http://myendpointaddress/graphql'})\n\n// Create a remoteExecutableSchema by specifying endpoint adddress and introspection schema:\nawait schemaGenerator.registerEndpoint({uri: 'http://myendpointaddress/graphql', introspectionSchema: myIntrospectionSchema})\n\n// Create a remoteExecutableSchema by passing in an ApolloLink instance\nawait schemaGenerator.registerEndpoint({link: myApolloLink})\n\n// Create a remoteExecutableSchema that uses an Authorization bearer token\nawait schemaGenerator.registerEndpoint({uri: 'http://myendpointaddress/graphql', authenticationToken: 'ey.......'})\n\n// Add a schema \nschemaGenerator.registerSchema(schema: myGraphQLSchema)\n\n// Add a type definition\nschemaGenerator.registerTypeDefinition(typeDefs: myTypeDefinitionString)\n    \n// Add a resolver function\nschemaGenerator.registerResolver(resolverFunction: myResolverFunction)\n\n// Generate the merged schema\nconst mySchema = schemaGenerator.generateSchema()\n```\n\nSee the [examples](./examples) folder for a complete example (coming soon).\n\n## addTypeNameField\n\nIf you add an Interface Types to your merged schema, you have to manually add the `__typeName` field to your resolvers. This helper function makes it easy to do so.\n\n```ts\n// Assuming you have created a remote schema mySchema with types Car and Boat\n\nconst schemaGenerator = new SchemaGenerator()\nschemaGenerator.registerEndpoint({uri: '...' })\n\nconst typeDefs = `\n    interface Verhicle {\n        maxSpeed: Float\n    }\n\n    extend type Car implements Vehicle { }\n\n    extend type Boat implements Vehicle { }\n    \n    extend type Query {\n        allVehicles: [Verhicle]\n    }`\n\nconst allVehiclesresolver = mergeInfo =\u003e ({\n    Query: {\n        allVehicles: {\n            async resolve(parent, args, context, info){\n                const newInfo = addTypeNameField(info)\n\n                const cars = mergeInfo.delegate('query', 'allCars', args, context, info)\n                const boats = mergeInfo.delgate('query', 'allBoats', args, context, info)\n\n                return [...cars, ...boats]\n            }\n        }\n    }\n})\n\nschemaGenerator.registerTypeDefinition(typeDefs)\nschemaGenerator.registerResolver(allVehiclesresolver)\n\nconst mergedSchema = schemaGenerator.generateSchema()\n```\n\n## addFields(mergeInfo: MergeInfo, fields: Array\u003cFieldNode | string\u003e)\n\nA generic helper for adding fields to the resolveInfo, by passing in a fieldName, or a complete FieldNode.\n\n```ts\n// Inside a resolver\nconst myField: FieldNode = { kind: 'Field', name: { kind: 'Name', value: 'myField' } }\nconst anotherField: 'anotherField'\n\naddFields(mergeInfo, [myField, anotherField])\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbrandwijk%2Fgraphql-gateway-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbrandwijk%2Fgraphql-gateway-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbrandwijk%2Fgraphql-gateway-tools/lists"}