public Object nodeLanguageFetcher(DataFetchingEnvironment env) { NodeContent content = env.getSource(); if (content == null) { return null; } List<String> languageTags = getLanguageArgument(env); GraphQLContext gc = env.getContext(); Node node = content.getNode(); Branch branch = gc.getBranch(); NodeGraphFieldContainer container = node.findVersion(gc, languageTags); // There might not be a container for the selected language (incl. fallback language) if (container == null) { return null; } // Check whether the user is allowed to read the published container boolean isPublished = container.isPublished(branch.getUuid()); if (isPublished) { gc.requiresPerm(node, READ_PERM, READ_PUBLISHED_PERM); } else { // Otherwise the container is a draft and we need to use the regular read permission gc.requiresPerm(node, READ_PERM); } return new NodeContent(node, container, languageTags); }
return null; return container.isPublished(gc.getBranch().getUuid()); }));