fabien0102
04/12/2018, 11:25 AMwoss
04/12/2018, 11:55 AMgrapqhl-yoga
exposes express
as a root key like server.express
which you can use for any kind of middleware. this will not work for subscriptions. https://github.com/LawJolla/prisma-auth0-example check that outfabien0102
04/12/2018, 12:39 PMwoss
04/12/2018, 12:42 PMMy goal is to provide a clean way to request my graphql api on another backend,
that seems like an API to me πwoss
04/12/2018, 12:44 PMdecorators
? that should work regradless is it an API or notfabien0102
04/12/2018, 1:01 PMapollo-client
but it's a little bit painfull for my collegue, he don't really like to have 50lines just for set the client (ws + http + auth links) and also to give a simple string (graphql query) to have some data.
My best idea for now is to try something with graphql-binding
to provide a "clean way" to interact with this graphql api. I just need to see how to setup this one to add the auth-token
in the websocket and http requests πfabien0102
04/12/2018, 1:02 PMdecorators
, but I guess it's just because this missunderstandingschickling
04/12/2018, 1:57 PMfabien0102
04/12/2018, 2:05 PMconst {
introspectSchema,
makeRemoteExecutableSchema
} = require("graphql-tools");
const { HttpLink } = require("apollo-link-http");
const fetch = require("node-fetch");
const { Binding } = require("graphql-binding");
(async () => {
try {
// Create the executable schema
const uri = "<http://localhost:6020>";
const link = new HttpLink({ uri, fetch });
const schema = await introspectSchema(link);
const executableSchema = makeRemoteExecutableSchema({
schema,
link
});
// Create the binding
const questionnaireAPI = new Binding({ schema });
questionnaireAPI.query
.questionnaire({ nisId: 2182 }, '{ id }')
.then(console.log) // -> null
.catch(console.log);
} catch (e) {
console.error(e);
}
})();
My current progression (I'v disabled the auth for now, just to have only one problem ^^) no more error, but my query is not workingβ¦fabien0102
04/12/2018, 2:06 PM{
questionnaire(nisId: 2182) {
id
}
}
My original query (working in insomnia)tim2
04/12/2018, 2:15 PMgraphql-binding
is exactly the right approachtim2
04/12/2018, 2:15 PMtim2
04/12/2018, 2:17 PMfabien0102
04/12/2018, 2:17 PMtim2
04/12/2018, 2:17 PMfabien0102
04/12/2018, 2:17 PMfabien0102
04/12/2018, 2:18 PMtim2
04/12/2018, 2:19 PMtim2
04/12/2018, 2:19 PMfabien0102
04/12/2018, 2:19 PMfabien0102
04/12/2018, 2:19 PMfabien0102
04/12/2018, 2:19 PMtim2
04/12/2018, 2:20 PMfabien0102
04/12/2018, 2:22 PMfabien0102
04/12/2018, 2:23 PMfabien0102
04/12/2018, 2:33 PM$ graphql-codegen-binding -s src/schema.graphql -g javascript -t qna.js
(node:12284) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1
): TypeError: Cannot read property 'split' of undefined
(node:12284) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js process with
a non-zero exit code.
π’fabien0102
04/12/2018, 2:34 PMtypescript
as generator and with an endpoint
instead of a local schemafabien0102
04/12/2018, 2:36 PMheaders
parsing πfabien0102
04/12/2018, 2:37 PMfabien0102
04/12/2018, 2:38 PM[undefined]
-> [undefined].map(h => h.split())
-> Boom!fabien0102
04/12/2018, 2:57 PMtim2
04/12/2018, 2:58 PMfabien0102
04/12/2018, 3:02 PMlawjolla
04/12/2018, 4:37 PMlawjolla
04/12/2018, 4:39 PMfabien0102
04/13/2018, 8:18 AMgraphql-codegen-binding ... -t MyService.js
2.
import { MyService } from "./MyService"
const myService = new MyService({endpoint: "", secret: ""})
// start playing \o/
Is it something in the roadmap for this kind of implementation or should I start to fork π ?tim2
04/13/2018, 8:20 AMfabien0102
04/13/2018, 8:20 AMtim2
04/13/2018, 9:36 AMfabien0102
04/13/2018, 9:38 AM