-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a GraphQL endpoint #134
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 09:04
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 09:10
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 09:14
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 09:19
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 09:34
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 16:43
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 17:18
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 17:20
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 17:22
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 17:25
Inactive
raspberrypiherokubot
temporarily deployed
to
editor-api-p-graphql-sp-0bly2n
February 17, 2023 17:46
Inactive
IzzySmillie
reviewed
Feb 20, 2023
loiswells97
reviewed
Feb 23, 2023
loiswells97
approved these changes
Feb 24, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 🚢
patch0
added a commit
that referenced
this pull request
Mar 2, 2023
# What's changed * Rewrite `oauth_user` helper into `identifiable` concern to use the Hydra Admin API library introduced in #134 * Changed the super class of the GraphQL controller to match the other API calls. * Upped the number of memoized helpers allowed by rubocop... 😅 # Points for consideration * When testing, the auth token has to be given in the headers, so I've added that in everywhere.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the start of a new GraphQL API that can be used by the editor-ui to fetch projects, components, images. GraphQL provides a documented, explorable API that allows the client to pull just the data it requires to fulfill the user's request.
This PR implements the ability to query the whole schema (
Project
,Component
,Image
), and provides just one mutationCreateProject
.Authorization is performed in the same way as the existing REST API, i.e. using a HTTP header
Authorization:
to provide the Hydra (v1) token.Example queries
Fetch all projects the user can read", showing fields useful for the "my projects" page
returns something like:
Note the use of obfuscated IDs, which is usual for GraphQL.
Here is a query to fetch a project that I've not given the auth token for:
The HTTP response is a 200, but the project is
null
, and data contains anerrors
array.If the project doesn't exist, no errors are returned, the project is simply
null
.Example mutation
This is an example of a mutation. This requires the
Authorization
header to be correctly set.Then here are the variables
And you have to set a header (which you can pinch from an existing editor-ui session).
This will then return
Tests
Tests have been added to cover the new code.
With the GraphQL queries and mutations, I've tried to split the tests at sensible boundaries. E.g. the
project_query_spec
tests theProjectType
and tries to draw a line between that and any sub types, e.g. the ComponentType, ImageType. I'd anticipate those being tested separately.Similarly the
projects_query_spec
doesn't test theProjectType
, but tests that an array of items with the correct__typename
is returned.