ilijanl / graphql-codegen-signed-operation Goto Github PK
View Code? Open in Web Editor NEWGraphQL codegen plugin for signing operation with some secret
Home Page: https://github.com/ilijaNL/graphql-codegen-signed-operation
License: MIT License
GraphQL codegen plugin for signing operation with some secret
Home Page: https://github.com/ilijaNL/graphql-codegen-signed-operation
License: MIT License
I'm working on a pull request for #1 but am unable to reproduce the same hash for a single operation.
Steps:
yarn install
and yarn build
graphql-codegen-signed-operation
directory in the relevant node_modules
previously installed (by npm install
)ln -s ../../graphql-codegen-signed-operation
npx graphql-codegen --config codegen.ts
I have about 28 hashes that are generated by this plugin and strangely enough, only a single one has a different hash when attempting to reproduce locally. Here's a copy of the definition:
export const UPDATE_CLIENT_PROFILE = gql`
mutation UpdateClientProfile(
$firstName: String
$lastName: String
$birthdate: AWSDate
) {
updateClientProfile(
firstName: $firstName
lastName: $lastName
birthdate: $birthdate
) {
userId
firstName
lastName
birthdate
}
}
`;
Deleting the link and reinstalling the package with npm install
generates the old hash.
Love the plugin, but have been having issues verifying any requests with fragments. I'm using AppSync and am handling the validation within a Lambda authorizer. Given how annoying AppSync is, there's a good chance this is an issue specific to using the event.requestContext.queryString
parameter provided. Here's an example of how we're using it:
const stableQuery = printExecutableGraphQLDocument(parse(queryString));
const expectedHash = createHmac("sha256", gqlSecret)
.update(stableQuery)
.digest("hex");
console.log(expectedHash, hash);
And here's an examples of outputs to demonstrate that it works correctly with no fragments.
INFO mutation ClientUpdate($input: MutationClientUpdateInput!) { clientUpdate(input: $input) }
INFO 2b6d3034ce59d737df0024ac903c9f02042bf86f341a289f97c4f4962f8658a2 2b6d3034ce59d737df0024ac903c9f02042bf86f341a289f97c4f4962f8658a2
And an example in which it breaks with a fragment.
INFO fragment UserFragment on User { __typename colorTheme firstName lastName profilePicture { __typename blurHash url } profilePictureBlurHash relationshipType userId } query GetClientProfile { getClientProfile { __typename birthdate numFriends relationshipType userType ...UserFragment } }
INFO ca7205cc9e733197724e2d0a35d68df73a1cfcfbadeb899be84b6b3de9d2f2c2 f842207215a93954b6473054cb1aa4fd3438e731946d4cddd84463ca9df26839
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.