orr
11/30/2017, 5:54 PM/me
endpoint as seen in many APIs. As per Graphcool's online examples, issuing a query from a resolver to the CRUD Api for the logged in user would look something like this:
const query = `
query me($id: ID!) {
viewer {
User(id: $id) {
< fields from the client go here >
}
}
}
`;
const variables = {
id: event.context.auth.nodeId,
};
const api = fromEvent(event).api('relay/v1');
const response = await api.request(
query,
variables,
);
My question is: Is there a more idiomatic way to do this in Graphcool? And would it make sense for the client to pass up a variable (potentially named fragment
) that will be used inside the query to fetch the fields the client is interested in?ersherr
11/30/2017, 6:13 PMersherr
11/30/2017, 6:13 PMpicosam
11/30/2017, 10:02 PM/userInfo
) instead of Graphcool’sorr
11/30/2017, 11:55 PMorr
12/01/2017, 12:01 AM.graphql
file. So, in attempting to create something like me.graphql
, one would have to define a MePayload
, which would need to be identical to the type User @model { ... }
from the types.graphql
file, and furthermore, the types of any nested relations on User
would also have to be re-declared inside of me.graphql
nilan
12/01/2017, 10:46 AMorr
12/01/2017, 4:05 PM